반응형
반응형
반응형
--------- 하나의 element 만 가져온다. ---------
document.getElementById("header1");

<h1 id="header1" onclick="getValue()">제목</h1>


--------- 여러개의 elements 를 가져온다. --------
document.getElementsByName("gender");
<input type="radio" name="gender" value="m">남
<input type="radio" name="gender" value="f">여
반응형

'프로그래밍 > Javascript' 카테고리의 다른 글

trim  (0) 2010.11.19
reload (refresh)  (0) 2010.03.23
부모창 = opener  (0) 2009.02.11
자바스크립트 예약어  (0) 2009.02.11
[Ext JS] form field 에서 keydown 등의 이벤트가 작동 안할때  (0) 2009.02.11
반응형
팝업창에서 부모창에 접근할때..


opener.document.all.xxx

이런식으로 한다.


ㅋㅋㅋㅋ

반응형
반응형

* 자바스크립트 예약어

 

abstract

 

case

 

continue

 

extends

 

for

 

import

 

long

 

private

 

static

 

throw

 

var

 

boolean

 

catch

 

default

 

false

 

function

 

in

 

native

 

protected

 

super

 

throw

 

void

 

break

 

char

 

do

 

final

 

goto

 

instanceof

 

new

 

public

 

switch

 

transient

 

while

 

byte

 

class

 

double

 

finally

 

if

 

int

 

null

 

return

 

synchronized

 

true

 

with

 

case

 

const

 

else

 

float

 

implements

 

interface

 

package

 

short

 

this

 

try

 

 

 


반응형
반응형

/* field 에 keydown 이벤트가 등록되어 있지 않아서 override */
Ext.override(Ext.form.TextField, {
 fireKey : function(e) {
  // To do : 요기다가 등록.
 }
 , initEvents : function() {
  this.el.on("focus", this.onFocus,  this);
  this.el.on("blur", this.onBlur,  this);
  
  // 필요한 부분은 등록해서 사용하면 됨.
  this.el.on("keydown", this.fireKey, this);
 }
});



ㄷㄷㄷ 이벤트가 있었다.. 삽질..
내가 찾는건 이거였다. 엔터 쳤을때... 실행.. ㅠㅠ

passowd_field.on("specialkey", function(el, e){
if(e.getKey() == 13) common_func.form_submit();
});

반응형

'프로그래밍 > Javascript' 카테고리의 다른 글

부모창 = opener  (0) 2009.02.11
자바스크립트 예약어  (0) 2009.02.11
input type text border style  (0) 2009.02.11
자바스크립트 객체지향  (0) 2009.02.11
JavaScript 객체표  (0) 2009.02.11
반응형

반응형
반응형
<Script language="javascript">
 var ajax = {};
 
 ajax.xhr = {
  $ : function(ObjId)
  {
   alert(ObjId);
  }
 };

 ajax.xhr.$('test');
</script>

기본적인 oop문법이다 오버라이딩정도면 충분히 oop와 비슷하게 만들수있을꺼같다.


반응형
반응형
JavaScript 객체표

 

※ 녹색은 네츠케이프, 혹은 익스플로러 전용으로만 사용되는 객체(속성,메소드)입니다

객체(Object)

속성(Property)

메소드(Method)

이벤트핸들러(Event Handler)

Anchor

name
text
x
y

 

 

anchors array

length

 

 

Applet

 

applet's methods

 

applets array

length

 

 

Area

hash
host
gostname
href
pathname
port
protocol
search
target

 

onClick
onmouseOut
onmouseOver

Array

length

concat
join
pop
push

reverse
shift
slice
sort
unshjft

 

Button

form
name
type
value

blur
click
focus

onClick
onmouseDown
onmouseUp

Checkbox

checked
defaultChecked
form
name
type
value

blur
click
focus

onClick
onmouseDown
onmouseUp 

Date

 

getDate
getDay
getFullYear
getHours
getMilliseconds
getMinutes
getMonth
getSeconds
getTime
getTimezoneOffset
getUTCDate
getUTCDay
getUTCFullYear
getUTCHours
getUTCMilliseconds
getUTCMinutes
getUTCMonth
getUTCSeconds
getYear
parse
setDate
setFullYear
setHours
setMilliseconds
setMinutes
setMonth
setSeconds
setTime
setUTCDate
setUTCHours
setUTCMilliseconds
setUTCMinutes
setUTCMonth
setUTCSeconds
setYear
goGMTString
toLocaleString
toString
toUTCString
UTC
valueOf

 

document

activeElement
alinkColor
all
Anchor
anchors
Applet
applets
Area
bgColor
body
charset
children

cookie
defaultCharset
domain
embed
embeds
expando

fgColor
Form
forms
Image
images

lastModified
Layer
layers

linkColor
Link
links
location
parentWindow
plugins

readyState
referrer
scripts
selection
styleSheets

title
URL
vlinkColor

clear
close
createElement
createStylesheet
elementFromPoint
getSelection

open
write
writeIn

 

FileUpload

form
name
type
value

blur
focus

select

onBlur
onFocus
onSelect

Form

action
Button
Checkbox
elements
encoding
FileUpload
Hidden
length
method
name
Password
Radio
Reset
Select
Submit
target
Text
Textarea

reset
submit

onReset
onSubmit

forms array

length

 

 

frames array

length

 

 

Hidden

form
name
type
value

 

 

History

current
length
next
previous

back
foward
go

 

history array

length

 

 

Image

border
complete
height
hspace
lowsrc
name
src
vspace
width
x
y

 

onAbort
onError
onLoad

images array

length

 

 

Layers

above
background
below
bgColor
clip
document
hidden
left
name
pageX
pageY
parentLayer
siblingAbove
siblingBelow
src
top
visibility
window
x
y
zindex

load
moveAbove
moveBelow
moveBy
moveTo
moveToAbsolute
resizeBy
resizeTo

onBlur
onFocus
onmouseOut
onmouseOver
onmouseUp

layers array

length

 

 

Link

hash
host
hostname
href
pathname
port
protocol
search
target
text
x
y

 

onClick
onmouseOut
onmouseOver

links array

length

 

 

location

hash
host
hostname
href
pathname
port
protocol
search

reload
replace

 

Math

E
LN2
LN10
LOG2E
LOG10E
PI
SQRT1_2
SQRT2

abs
acos
asin
atan
atan2
ceil
cos
exp
floor
log
max
min
pow
random
round
sin
sqrt
tan

 

MimeType

description
enabledPlugin
suffixes
type

 

 

mimeTypes array

length

 

 

navigator

appCodeName
appMinorVersion
appName
appVersion
browserLanguage
cookieEnabled
cpuClass
languages
mimeTypes

platform
plugins
systemLanguage

userAgent
userLanguage
userProfile

javaEnabled
preference
savePreferences
taintEnabled

 

Number

MAX_VALUE
MIN_VALUE
NaN
NEGATIVE_INFINITY
POSITIVE_INFINITY

toString
valueOf

 

Option

defaultSelected
index
selected
selectedIndex
text
value

 

 

options array

length

 

 

Password

defaultValue
form
name
type
value 

blur
focus
select

onBlur
onChange
onFocus
onKeydown
onKeypress
onKeyup
onSelect

Plugin

description
filename
name

refresh

 

plugins array

length

 

 

Radio

checked
defaultChecked
form
name
type
value

blur
click
focus

onClick
onmouseDown
onmouseUp 

radio array

length

 

 

Reset

form
name
type
value

blur
click
focus

onClick
onmouseDown
onmouseUp 

screen

availHeight
availLeft
availTop

availWidth
BufferDepth
colorDepth
height
pixelDepth
updayeInterval
width

 

 

Select

form
length
name
options
selectedIndex
type

blur
focus

onChange

String

length

anchor
big
blink
bold
charAt
charCodeAt
concat
fixed
fontcolor
fontsize
formCharCode
indexOf
italics
lastIndexOf
link
match
replace
search
slice
small
split
strike
sub
substr
substring
sup
toLowerCase
toUpperCase 

 

Submit

form
name
type
value

blur
click
focus

onClick
onMouseDown
onMouseUp

Text

defaultValue
form
name
type
value

blur
click
focus
select

onBlur
onChange
onFocus
onKeydown
onKeyup
onSelect

Textarea

defaultValue
form
name
type
value

blur
click
focus
select

onBlur
onChange
onFocus
onKeydown
onKeyup
onSelect

window

clientInformation
closed

defaultStatus
dialogArguments
dialogHeight
dialogLeft
dialogLeft
dialogTop
dialogWidth

document
event
frames
history
innerHeight
innerWidth

length
location
locationbar
menubar

name
navigator
offscreenBuffering
opener
outerHeight
outerWidth
pageXOffset
pageYOffset

parent
personalbar
screen
screenX
screenY
scrollbars

self
status
statusbar

toolbar
top

alert
back
blur

close
confirm
find
focus
forward
home
moveBy
moveTo
navigate

open
print
prompt
resizeBy
resizeTo

scroll
scrollBy
scrollTo
stop

onBlur
onError
onFocus

onLoad
onResize
onUnload

 


반응형

'프로그래밍 > Javascript' 카테고리의 다른 글

input type text border style  (0) 2009.02.11
자바스크립트 객체지향  (0) 2009.02.11
이메일 체크 - 정규표현식으로  (0) 2009.02.11
선택 영역 복사하기 자바스크립트  (0) 2009.02.11
tr, td 추가 innerHTML  (1) 2009.02.11
반응형

/*
 이메일을 체크하기 위한 함수
 인수로는 element(input type=text)를 받음.

 정규 표현식 ==>

^[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*\.[a-zA-Z]{2,3}$
                 ^[0-9a-zA-Z] --> 첫글자는 숫자또는 영문자
                         [-_\.]? --> - 또는 _ 또는 . 이 0번 또는 1번
                  [0-9a-zA-Z] --> 숫자또는 영문자
([-_\.]?[0-9a-zA-Z])*@ --> @앞에(-,_,. 이 0~1번, 그 뒤에는 숫자,영문자)이 한번 또는 여러번
                  [0-9a-zA-Z] --> @ 뒤에는 숫자 또는 영문자
                          [-_\.]? --> - 또는 _ 또는 . 이 0번 또는 1번
([-_\.]?[0-9a-zA-Z])*\. --> . 앞에(-,_,. 이 0~1번, 그 뒤에는 숫자,영문자)이 한번 또는 여러번
               [a-zA-Z]{2,3}$ --> . 뒤 마지막 문자열은 영문자가 2~3개

   가능한 형식 예 : aaa@bbb.com  a7a.dd@bbbb.pe.kr.com  777_d-3@bbb.com
불가능한 형식 예 : -aaa@bbb.com  a#aa@co.kr  aa@bb@cc.com  aaa@bbb.c  aaa@bbb.comp
*/

function valid_email(ele) {
 re=/^[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*\.[a-zA-Z]{2,3}$/i;
 
 if(!re.test(ele.value)) {
  alert("메일형식이 맞지 않습니다.\n 다시 입력해주세요.\n");
  ele.select();
  ele.focus();
  return false;
 }
 else return true;
}


반응형

'프로그래밍 > Javascript' 카테고리의 다른 글

자바스크립트 객체지향  (0) 2009.02.11
JavaScript 객체표  (0) 2009.02.11
선택 영역 복사하기 자바스크립트  (0) 2009.02.11
tr, td 추가 innerHTML  (1) 2009.02.11
table 에 tr 추가 하기  (0) 2009.02.11
반응형

TextRange 객체의 execCommand 메서드를 사용하면 되겠습니다.

 

익스플로러 전용입니다.

 

선택된 내용은 클립보드로 복사됩니다.

 

<html>
<head>
<title> 선택영역 복사하기 </title>
<script language="javascript">
function _copy()
{
 document.selection.createRange().execCommand("copy");
}
</script>

</head>

<body>
동해물과 백두산이 마르고 닳도록<br>
하느님이 보우하사 우리나라 만세<br>
무궁화 삼천리 화려강산<br>
대한사람 대한으로 길이 보전하세
<input type="button" value="copy" >
</body>
</html>



반응형

'프로그래밍 > Javascript' 카테고리의 다른 글

JavaScript 객체표  (0) 2009.02.11
이메일 체크 - 정규표현식으로  (0) 2009.02.11
tr, td 추가 innerHTML  (1) 2009.02.11
table 에 tr 추가 하기  (0) 2009.02.11
Microsoft.XMLHTTP과 Msxml2.XMLHTTP의 차이  (0) 2009.02.11
반응형

<BODY>
<TABLE id="a1" border=1>
</TABLE>

<input type="button" value="추가">

</BODY>

id="a1" 이라는 이라는 테이블이 존재하는데 속이 비어있죠~

그렇다면 저 안에 무언가 들어 가게 하기 위해서는 <tr><td></td></tr> 이렇게 있어야 한개의 테이블이 형성된다는 건 html 을 안다면 아실내용인거니 그걸 어떻게 생성하느냐~

초간단하게 설명하자면

 insertRow() -> tr 을 만듭니다.

 insertCell() -> td 를 만들어 냅니다.

그럼 inRow() 함수를 다음처럼 추가하면


<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function inRow(){
 document.getElementById('a1').insertRow().insertCell().innerHTML = "test";
}
//-->
</SCRIPT>
</HEAD>

<BODY>
<TABLE id="a1" border=1>
</TABLE>
<input type="button" value="추가">
</BODY>


 

순서대로 읽으면 해석 끝나는 군요 ㅋ

document(현재페이지에).getElementById('a1')(a1이라는 id를 가진곳을찾아서).insertRow()(tr을넣고).insertCell(td를넣은뒤).innerHTML(들어가게 하라) = "test";(이런내용을...)

흠...안쉽나..?

 

암튼 이렇게 해 놓으면 함수를 호출할때 마다 test라고 써진 부분이 계속 추가가 되겠죠

그럼 test 대신 뭔가 이름을 가진걸 계속 추가를 해줘봅시다. 다음과 같이...ㅋ

 

<!--
function inRow(){

Merong = "<input type='text' name='a2'>";
 document.getElementById('a1').insertRow().insertCell().innerHTML = Merong;
}
//-->

 

그럼 name=a2 라고 가진 textbox 가 계속 생성이 되겠죠?

자~ 이때!!!! getElementsByName 이 JJAN 하고 등쟝해서 생성된 a2의 총갯수를  ~ 배열로 읽어오게 됩니다.

그럼 또 다시 이렇게 추가를 해줍니다.

 

<!--
function inRow(){

Merong = "<input type='text' name='a2'>";

JJAN = document.getElementsByName('a2') //a2를 배열로 불러와서 JJAN 에 담습니다.
 document.getElementById('a1').insertRow().insertCell().innerHTML = Merong + JJAN.length;
}
//-->

 

length 를 찍어주면 현재 갯수가 어케 찍히는지 알겠죠~ ? (배열은 0부터 시작하니깐 (JJAN.length+1)로 해서 산식을 먼저 더해주면 1부터 출력이 되겠군요)

반응형

+ Recent posts