document 개체는 현재 열려있는 HTML 문서를 말하며 script를 통해 접속하고 제어를 가능하게 한다.
document .propertyName
document .methodName(parameters )
document .eventName ='JsCode '
인수
propertyName : (속성명)
적용할 수 있는 속성들 중의 하나이다.
methodName : (메서드명)
적용할 수 있는 메서드들 중의 하나이다.
parameters : (인수)
methodName 에 따라 필요한 인수이다.
eventName : (이벤트처리자명)
적용할 수 있는 이벤트처리자들 중의 하나이다.
JsCode : (수행문)
이벤트 가 발생되었을 때 수행될 수행문이다.
특기
이 개체의 스크립트들은 IE3.0 부터 적용된다.
document 개체는 HTML 문서의 내용을 점검, 수정 혹은 추가할 때 사용하거나 문서 속에서 이벤트를 처리할 때 사용한다.
웹 페이지에서 document 개체는 window 개체의 document 속성을 통하여 참조하거나 혹은 직접적으로 참조한다.
document 개체는 모든 주 문서에서 항상 참조할 수 있으나, 가벼운(lightweight) DHTML 비헤이비어세 사용되는 HTML 컴포넨트(HTC : HTML Component) 파일은 없다.
이는 HTC 파일에서 document 개체를 사용할 수 없을 때 지정하는 것이기 때문이다.
결과적으로 가벼운 비헤이버는 일반적인 비헤이버보다 빠르고 효과적으로 적용된다.
그러나 가벼운 DHTML 비헤이버들도 일반적인 DHTML 비헤이버와 마찬가지로 주 문서의 document 개체에 접속할 수 있다.
ondocumentready 이벤트는 DHTML 비헤이버에 주 웹문서의 document 개체에 비헤이버가 포함되어 있다는 것을 알린다.
ondocumentready 이벤트가 발생되면 비헤이버는 주 document 개체를 처리하기 시작한다.
비헤이버 속의 스크립트로 HTC 파일이나 주 문서의 document 개체를 참조할 수 있다.
HTC 파일 속의 스크립트는 element .document 로 주 문서의 document 개체를 참조할 수 있다.
적용
개체 script HTML 규격 IE
custom [ oVal ]= custom .document < > 없음 IE5(win32,unix) window [ oVal ]= window .document < > 없음 IE3.02(win16,win32,mac),win4.0(ce,unix)
document 설명을 위한 예제
설명을 위한 예제
<newns:aaa>
<import namespace="otherNS" url="exp/newTag.htc">
<form id="formId" name="formName"><input id="inObj" value="예제 입력"><input type="button" value="단추"></form><div id="sampleObj" name="sampleName" title="설명을 위한 예제" align="center" style="border:solid 1 blue;width:700"><embed src="http://trio.co.kr/sound/flute3.mid" loop="1" autostart="false"> 설명을 위한 예제</div>
<script>oObj=document;</script></import></newns:aaa>
컬렉션 설명과 예제 코드 결과 참고
all
개체에 포함되어 있는 모든 엘레멘트들의 배열변수를 참조하고 반환한다.
<SCRIPT>document.write(oObj.all.length)</SCRIPT>
276
클릭
anchors
문서의 모든 name 나 id 속성을 갖는 a 개체들의 컬렉션을 반환한다.
<SCRIPT>document.write(oObj.anchors.length)</SCRIPT>
3
applets
문서의 모든 applet 개체들의 컬렉션을 반환한다.
예:<SCRIPT>document.write(oObj.applets.length)</SCRIPT>
보안관계상 차단되므로 코드 제거했슴.
childNodes
개체의 바로 종속된 자식들의 엘레멘트 개체들과 TextNode 개체들의 배열변수를 참조하고 반환한다.
<SCRIPT>document.write(oObj.childNodes.length)</SCRIPT>
2
embeds
문서의 모든 embed 개체들의 컬렉션을 반환한다.
<SCRIPT>document.write(oObj.embeds.length)</SCRIPT>
1
forms
문서의 모든 form 개체들의 컬렉션을 반환한다.
<SCRIPT>document.write(oObj.forms.length)</SCRIPT>
1
frames
문서의 모든 frame 개체들의 컬렉션을 반환한다.
<SCRIPT>document.write(top.frames.length)</SCRIPT>
0
images
문서의 모든 img 개체들의 컬렉션을 반환한다.
<SCRIPT>document.write(oObj.images.length)</SCRIPT>
22
links
문서의 모든 href 속성을 갖는 a 개체와 모든 area 개체들의 컬렉션을 반환한다.
<SCRIPT>document.write(oObj.links.length)</SCRIPT>
51
namespaces
문서의 모든 namespace 개체들의 컬렉션을 반환한다.
<SCRIPT>document.write(oObj.namespaces.length)</SCRIPT>
scripts
문서의 모든 script 개체들의 컬렉션을 반환한다.
<SCRIPT>document.write(oObj.scripts.length)</SCRIPT>
21
styleSheets
문서의 모든 link 에 연결된 styleSheet 개체들과 style 개체들의 컬렉션을 반환한다.
<SCRIPT>document.write(oObj.styleSheets.length)</SCRIPT>
2
각종 입력폼 요소들, 앵커, 배경색상이나 문자색상 같은 공통 문서 속성들에도 접속을 가능하게 한다.
activeElement 속성
IE4 -
⇒
document 개체에 포함되어 있는 개체가 초점을 받고 활성화된 활성 엘레멘트(
activeElement )를 반환한다.
문법: [oVal =] documentObj .activeElement
코드: formName.inObj.focus();document.write(document.activeElement.id);
결과: inObj
bgColor 속성
IE
⇒ 문서의 배경 색상을 rrggbb
색상이나 색상명칭 으로 반환하거나 지정한다.
문법: documentObj .bgColor [= clrVal ]
코드: document.write(oObj.bgColor);
결과:
alinkColor 속성
IE3.02 NS2
⇒ 활성 링크의 색상을 rrggbb
색상이나 색상명칭 으로 반환하거나 지정한다.
문법: documentObj .alinkColor [=colorVal ]
코드: document.write(document.alinkColor);
결과:
all (
컬렉션 ) 속성
IE4 -
⇒
document 개체에 포함되어 있는 문서의 모든(
all ) 개체들의 배열변수
all 컬렉션을 참조한다.
문법: [ cVal =] documentObj .all
문법: [oVal =] documentObj .all(index )
문법: [oVal =] documentObj .all(idVal )
코드: document.write(document.all)
결과: [object HTMLAllCollection] 코드: document.write(document.all.length)
결과: 691
코드: document.write(document.all(1).nodeName)
결과: HEAD 코드: document.write(document.all(3).nodeName,' ',document.all(3).innerHTML)
결과: META
anchors (
컬렉션 ) 속성
IE4 NS4
⇒
document 개체에 포함되어 있는
anchor 개체들의 배열변수
anchors 컬렉션을 조회하고 호출한다.
문법: [ cVal =] documentObj .anchors
문법: [oVal =] documentObj .anchors(index )
문법: [oVal =] documentObj .anchors(idVal )
코드: document.write(document.anchors.length)
결과: 11
코드: document.write(document.anchors[2].name)
결과: all
applets (
컬렉션 ) 속성
IE3.02 NS3
⇒
document 개체에 포함되어 있는
applet 개체들의 배열변수
applets 컬렉션을 조회하고 호출한다.
문법: [ cVal =] documentObj .applets
문법: [oVal =] documentObj .applets(index )
문법: [oVal =] documentObj .applets(idVal )
코드: 예: document.write(oObj.applets.length+' | '+oObj.applets[0].src);;
결과: 보안관계상 차단되므로 코드 제거했슴.
body (
개체 ) 속성
IE4 NS6 (
<BODY > 엘레멘트)
⇒ 문서 본체를 참조한다.
문법: [oVal =] documentObj .body
코드: document.write(document.body.clientWidth+' | '+document.body.clientHeight);
결과: 1264 | 2938
bgColor 속성
IE
⇒ 문서의 배경 색상을 rrggbb
색상이나 색상명칭 으로 반환하거나 지정한다.
문법: documentObj .bgColor [= clrVal ]
코드: document.write(oObj.bgColor);
결과:
characterset 속성
- NS6
⇒ 지정된
document 개체의 문자세트를 반환하거나 지정한다.
문법: documentObj .characterset [=sVal ]
코드: document.write(document.characterset);
charset 속성
IE4 -
⇒ 개체 엔코딩에 사용된 문자세트를 반환하거나 지정한다.
문법: documentObj .charset [=sVal ]
코드: document.write(document.charset);
결과: EUC-KR
classes (배열변수) 속성
- NS4
⇒ 지정된
document 개체의 class 배열변수를 반환하거나 지정한다.
문법: documentObj .classes [= oVal]
코드: document.write(document.classes);
compatMode 속성
IE
⇒
IE6 개체에 표준에 부합하는모드를 적용하는가를 나타내는 값을 반환하거나 설정한다.
문법: document .compatMode
코드: document.write(document.compatMode);
결과: CSS1Compat
contextual 속성
- NS4
⇒ 개별 HTML tag의 style을 설정할 수 있는 style 개체를 지정하는 문맥 선택에 사용된다.
문법: [ document .] contextual(context1,...[ contextN,] affectedStyle )
cookie 속성
IE3.02 NS2
⇒ 지정된
document 개체와 연관된 보이며 만료되지 않은 쿠키 리포드를 문자열로 반환하거나 지정한다.
문법: documentObj .cookie [= sVal]
코드: document.write(oObj.cookie);
결과:
defaultCharset 속성
IE4 -
⇒ 지정된
document 개체의 디폴트 문자세트를 반환하거나 지정한다.
문법: documentObj .defaultCharset [=sVal ]
코드: document.write(document.defaultCharset);
결과: undefined
designMode 메서드
IE5 -
⇒ 개체가 편집될 수 있는가를 나타내는 디자인 모드를 반환한다.
문법: documentObj .designMode [=sVal ]
코드: document.write(document.designMode)
결과: off
dir 메서드
IE NS
⇒ 개체의 읽는 순서를 왼쪽에서부터인가 오른쪽에서 부터인가 를 반환하거나 설정한다.
문법: documentObj .dir [=sVal ]
코드: document.write(document.dir='ltr')
결과: ltr
doctype 속성
IE6 NS6
⇒ 지정된
document 개체의 문서 타입을 반환한다.
문법: [oVal =] documentObj .doctype
코드: document.write(document.doctype);
결과: [object DocumentType]
documentElement 속성
IE5 NS6
⇒ 문서의 최상위(root) 엘레멘트를 반환한다.
문법: [oVal =] documentObj .documentElement
코드: document.write(document.documentElement)
결과: [object HTMLHtmlElement]
코드: document.write(document.documentElement.nodeName)
결과: HTML
domain 속성
IE4 NS3
⇒
document 개체가 있는 서버의 안전 도메인 이름을 반환하거나 설정한다. PC상 화일 주소에는 domain이 없다.
문법: documentObj .domain =sVal
코드: document.write(document.domain);
결과: koxo.com
embeds (
컬렉션 ) 속성
IE4 NS3
⇒ 현재
document 개체 속에 깔린(embedded) 개체들을 배열변수
embeds 을 참조한다. 미디나 플래쉬가 해당된다.
문법: [oVal =] documentObj .embeds
문법: [oVal =] documentObj .embeds(index )
문법: [oVal =] documentObj .embeds(idVal )
expando 속성
IE4 -
⇒ 개체 내부에서 애트리뷰트를 생성할 수 있는가를 반환하거나 설정한다.
문법: documentObj .expando [= bVal ]
코드: document.write(oObj.expando);
결과: undefined
fgColor 속성
IE3.02 NS2
⇒
document 개체의 글자색상을 rrggbb
색상이나 색상명 으로 반환하거나 지정한다.
문법: documentObj .fgColor [= clrVal ]
코드: document.write(document.fgColor);
결과:
fileCreatedDate 속성
IE4 -
⇒ 읽기 전용으로 지정된
document 개체의 파일 생성일자를 반환한다.
문법: [ dVal =] documentObj .fileCreatedDate
코드: document.write(document.fileCreatedDate);
결과: undefined
fileModifiedDate 속성
IE4 -
⇒ 읽기 전용으로 지정된
document 개체의 파일 최종 수정일자를 반환한다.
문법: [ dVal =] documentObj .fileModifiedDate
코드: document.write(document.fileModifiedDate);
결과: undefined
fileSize 속성
IE4 -
⇒ 읽기 전용으로 지정된
document 개체의 파일 크기를 반환한다.
문법: [iVal =] documentObj .fileSize
코드: document.write(document.fileSize);
결과: undefined
formName 속성
IE4 NS3
document 개체 속의 각 입력폼은 각각의
document 개체 속성을 갖는다.
document 개체 속의
<FORM NAME="formName "> 으로 지정된
form 개체명을 각각 참조한다.
문법: documentObj .forms(idVal )
문법: documentObj .forms['formName' ]
코드: document.write(document.forms[0].name+' | '+document.forms('formName').id)
결과:
코드: document.write(document.forms('formName').elements.length+' | '+document.forms('formName').elements[0].type)
결과:
forms (
컬렉션 ) 속성
IE4 NS2
⇒
document 개체에 포함되어 있는
form 개체들의 배열변수
forms 컬렉션을 참조한다.
문법: [oVal =] documentObj .forms
문법: [oVal =] documentObj .forms(index )
문법: [oVal =] documentObj .forms(idVal )
코드: document.write(document.forms.length+' | '+document.forms[0].elements[0].nodeName)
결과: 1 | INPUT
frames (
컬렉션 ) 속성
IE4 NS
⇒
document 개체에 포함되어 있는
frame 개체들의 배열변수
frames 컬렉션을 참조한다.
문법: [oVal =] documentObj .frames
문법: [oVal =] documentObj .frames(index )
문법: [oVal =] documentObj .frames(idVal )
코드: document.write(top.document.frames.length)
결과:
코드: document.write(top.document.frames[0].name)
결과:
height 속성
- NS4
⇒
document 개체의 높이를 반환한다.
문법: [ iVal documentObj .height
코드: document.write(document.height)
ids (
개체 ) 속성
- NS4
⇒ 개별 HTML tags에 적용될 style을 지정하는 style 개체를 생성한다.
문법: documentObj .ids .idValue
images (
컬렉션 ) 속성
IE4 NS3
⇒
document 개체에 포함되어 있는
Image 개체들의 배열변수
images 컬렉션을 참조한다.
문법: [ cVal =] documentObj .images
문법: [oVal =] documentObj .images(index )
문법: [oVal =] documentObj .images(idVal )
코드: document.write(document.images.length+' | '+document.images[0].src)
결과: 53 | http://koxo.com/lang/gif/rfobject.gif
implementation (
개체 ) 속성
IE6 NS6
⇒
document 개체의 적용(
implementation ) 개체(EXT, CAP, NUM, SCRL, OVR, REC, 등)를 반환한다.
문법: [oVal =] documentObj .implementation
코드: document.write(document.implementation)
결과: [object DOMImplementation]
코드: document.write(document.implementation.hasFeature('html','1.0'))
결과: true
lastModified 속성
IE3.02 NS2
⇒ 읽기 전용으로
document 개체의 최종 수정일자를 반환한다.
문법: [ dVal =] documentObj .lastModified
코드: document.write(document.lastModified)
결과: 07/26/2025 03:15:39
layers (
컬렉션 ) 속성
- NS4
⇒
document 개체에 포함되어 있는
layer 개체의 배열변수
layers 컬렉션을 참조한다.
문법: [oVal =] documentObj .layers[ (idVal )]
linkColor 속성
IE3.02 NS2
⇒
document 개체의 연결색상을 rrggbb
색상이나 색상명칭 으로 반환하거나 지정한다.
문법: documentObj .linkColor [= clrVal ]
코드: document.write(document.linkColor)
결과:
links (
컬렉션 ) 속성
IE3.02 NS2
⇒
document 개체에 포함되어 있는
link 개체의 배열변수
links 컬렉션을 참조한다.
문법: [oVal =] documentObj .links
문법: [oVal =] documentObj .links(index )
문법: [oVal =] documentObj .links(idVal )
코드: document.write(document.links.length+' | '+document.links[0].href)
결과: 148 | http://koxo.com/lang/js/object/document.html#propertyJump
location (
개체 ) 속성
IE3.02 NS2
⇒ 이 속성은 윈도우의 현재 URL 상세를 갖고 그 값은 항상 윈도우(
window )의
location 개체이다.
문법: documentObj .location [=sVal ]
코드: document.write(document.location);
결과: http://koxo.com/lang/js/object/document.html
코드: document.write(top.document.location);
결과: http://koxo.com/lang/js/object/document.html
parentWindow 속성
IE4 -
⇒ 읽기 전용으로
document 개체의 모체 윈도우를 반환한다.
문법: [oVal =] documentObj .parentWindow.location
코드: document.write(document.parentWindow.location)
결과:
plugins (
컬렉션 ) 속성
IE4 NS3
⇒
document 개체에 포함되어 있는
plugin 개체의 배열변수
plugins 컬렉션을 참조한다.
문법: [oVal =] documentObj .plugins
문법: [oVal =] documentObj .plugins(index )
문법: [oVal =] documentObj .plugins(idVal )
코드: document.write(oObj.plugins.length)
결과: 1
protocol 속성
IE3.02 -
⇒
document 개체의 주소(URL)에 연관된 프로토콜()protocol을 반환한다.
문법: documentObj .protocol [=sVal ]
코드: document.write(document.protocol)
결과: undefined
readyState 속성
IE4 -
⇒
document 개체의 준비 상황을 반환한다.
문법: [sVal =] documentObj .readyState
코드: document.write(document.readyState)
결과: loading
referrer 속성
IE3.02 NS2
⇒ 다른 문서의
link 개체를 클릭하여 현재
document 개체를 호출하여 연결시킨 문서의 주소(URL)를 반환한다.
PC상 화일 주소는 반환하지 않는다.
문법: [sVal =] documentObj .referrer
코드: document.write(document.referrer)
결과:
scripts (
컬렉션 ) 속성
IE4 NS
⇒
document 개체에 포함되어 있는
script 개체의 배열변수
scripts 컬렉션을 참조한다.
문법: [oVal =] documentObj .scripts
문법: [oVal =] documentObj .scripts(index )
문법: [oVal =] documentObj .scripts(idVal )
코드: document.write(document.scripts.length)
결과: 137
코드: document.write(document.scripts[7].innerHTML)
결과: oObj=document;
selection (
개체 ) 속성
IE4 -
⇒
document 개체의 선택한 개체를 반환한다.
문법: documentObj .selection
코드: document.write(document.selection,' ',document.selection.type)
결과:
styleSheets (
컬렉션 ) 속성
IE4 NS6
⇒
document 개체에 포함되어 있는
styleSheet 개체의 배열변수
styleSheets 컬렉션을 참조한다.
문법: [oVal =] documentObj .styleSheets
문법: [oVal =] documentObj .styleSheets(index )
문법: [oVal =] documentObj .styleSheets(idVal )
코드: document.write(document.styleSheets.length)
결과: 2
코드: document.write(document.styleSheets[0].type)
결과: text/css
코드: document.write(document.styleSheets[1].cssText)
결과: undefined
tags (
개체 ) 속성
- NS4
⇒ HTML tag의 style을 지정할 수 있는 style 개체를 생성한다.
tagName 은 DIV, SPAN 등 대소문자 구별없이 HTML 엘레맨드 이름이다.
문법: documentObj .tags .tagName
title 속성
IE3.02 NS2
⇒
document 개체의
<TITLE></TITLE> 속에 기술된 문서의 제목을 반환하거나 지정한다.
문법: documentObj .title [=sVal ]
코드: document.write(document.title)
결과: KoXo 자바스크립트 - 개체(object) - *** | document
uniqueID 속성
IE5 -
⇒ 자동적으로 생성된 개체의 유일한 인식자(id) 문자열을 반환한다.
문법: [sVal =] documentObj .uniqueID
코드: document.write(document.uniqueID)
결과: undefined
URL 속성
IE4 NS3
⇒
document 개체의 주소인 URL을 반환하거나 지정한다.
문법: documentObj .URL [=sVal ]
코드: document.write(document.URL)
결과: http://koxo.com/lang/js/object/document.html
URLUnencoded 속성
IE
⇒
document 개체의 주소인 URL을 엔코딩하지 않은 상태로 반환한다.
문법: [sVal =] documentObj .URLUnencoded
코드: document.write(document.URLUnencoded)
결과: undefined
vlinkColor 속성
IE3.02 NS2
⇒
document 개체의 방문했던 연결의 색상을 rrggbb
색상이나 색상명칭 으로 반환하거나 지정한다.
문법: documentObj .vlinkColor [= clrVal ]
코드: document.write(document.vlinkColor);
결과:
XMLDocument 속성
IE
⇒
document 개체에 있는
DOM (
D ocument
O bject
M odel)의 문서
XML 엘레멘트를 반환한다.
문법: [sVal =] documentObj .XMLDocument
코드: document.write(document.XMLDocument)
결과: undefined
XSLDocument 속성
IE
⇒
document 개체에 있는
DOM (
D ocument
O bject
M odel)의 문서 최상위
XLS 엘레멘트를 반환한다.
문법: [sVal =] documentObj .XSLDocument
코드: document.write(document.XSLDocument)
결과: undefined
width 속성
- NS4
⇒
document 개체의 너비를 픽셀 단위로 반환하거나 지정한다.
문법: documentObj .width [=iVal ]
코드: document.write(document.width)
attachEvent 메서드
IE5 -
⇒ 이벤트에 특정 기능을 묶어, 기능함수가 개체에서 이벤트가 발생되면 언제나 호출되게 한다.
이벤트의 제거는
detachEvent 에서 한다. 반환값은 부울값이다.
문법: [bVal =] documentObj .object.attachEvent(event,functObj )
event는 필수요소이고, 표준 이벤트 문자열이다. functObj도 필수요소이고 이벤트가 발생되면 호출될 기능함수이다.
코드: function callFunc(){alert('ondblclick 이벤트 발생')}document.attachEvent('ondblclick',callFunc)
결과: // 문서 위 아무데서나 더블클릭 해 보라.
코드: <INPUT type=button value="attachEvent 재설정" onclick="document.detachEvent('ondblclick',callFunc);document.attachEvent('ondblclick',callFunc)"></SPAN>
결과:
captureEvents 메서드
- NS4
⇒ 특정 종류의 모든 이벤트를 포착하도록 지시한다.
이벤트 목록 을 참고하라.
문법: documentObj .captureEvent ('eventType')
clear 메서드
- NS2
⇒ script를 포함하여 현재 문서를 모두 지운다.
IE 에서는 지원되지 않는다.
문법: documentObj .clear() ;
close 메서드
IE3.02 NS2
⇒ 먼저
document .
open 메서드로 연 문서를
document .
write 나
documentObj .
writeln 메서드로 디스플레이 시키고 모든 인스탄스를 닫는다.
window .
close 를 참고하라.
문법: documentObj .close()
createAttribute 메서드
IE NS6
⇒ 엘레멘트 새로운 속성을 생성한다.
문법: documentObj .createAttribute ="attrString" ;
코드: document.write(document.createAttribute='title="test"')
createCDATASection 메서드
- NS6
⇒ 새로운 CDATA 항목을 생성한다.
문법: documentObj .createCDATASection ="cdataString" ;
createComment 메서드
IE NS6
⇒ 새로운 주석 항목을 생성한다.
문법: documentObj .createComment("cmtString" ) ;
코드: comObj=document.createComment('주석 항목의 생성');document.write(comObj.nodeName,' ',comObj.nodeValue)
결과: #comment 주석 항목의 생성
createDocumentFragment 메서드
IE NS6
⇒ 문서의 새로운 문서를 생성한다.
문법: documentObj .createDocumentFragment ="dfString" ;
코드: document.write(document.createDocumentFragmentt='새로운 문서의 생성')
결과: 새로운 문서의 생성
createElement 메서드
IE4 NS6
⇒ 지정한 태그로 새로운 엘레멘트를 생성한다.
문법: documentObj .createElement ="elemString" ;
코드: elemA=document.createElement('DIV');elemA.text='elemText';document.write(elemA.text)
결과: elemText
createEntityReference 메서드
- NS6
⇒ 새로운 문자 엔티티 참조를 생성한다.
문법: documentObj .createEntityReference ="entrefString" ;
createEventObject 메서드
IE4 NS6
⇒
fireEvent 메서드를 사용하여 이벤트 정보를 전달하는
event 개체를 생성한다.
문법: documentObj .createEventObject ="codeString" ;
코드: <BUTTON onclick="eventObj=document.createEventObject();document.fireEvent('onclick',eventObj);alert(eventObj.type);">예제 클릭</BUTTON>
결과: 예제 클릭
createProcessingInstruction 메서드
- NS6
⇒ 새로운 처리 방식의 지시를 생성한다.
문법: documentObj .createProcessingInstruction ="codeString" ;
createStyleSheet 메서드
IE4 -
⇒ 문서에 새로운 스타일쉬트를 생성한다.
문법: documentObj .createStyleSheet("cssString" ) ;
코드: <SCRIPT>document.write(document.createStyleSheet('./exp/samp.css').cssText);</SCRIPT> <U class=samp>test Sample</U>
결과: test Sample
createTextNode 메서드
IE5 NS6
⇒ 지정된 값으로 새로운 텍스트 노드를 생성한다.
문법: documentObj .createTextNode("textString" ) ;
코드: testObj=document.createTextNode('comment');document.write(testObj.nodeName+' | '+testObj.nodeValue)
결과: #text | comment
elementFromPoint 메서드
IE4 -
⇒ 포인터
x ,
y 좌표의 엘레맨트 개체를 반환한다.
문법: documentObj .elementFromPoint(x,y )
코드: document.write(document.elementFromPoint(100,100))
결과: [object HTMLTableCellElement]
코드: document.write(document.elementFromPoint(100,100).nodeName)
결과: TH
execCommand 메서드
IE4 -
⇒ 현재 문서에서
commandString 으로 지정한 작업을 수행한다. 참고:
command 목록
문법: documentObj .execCommand(commandString )
코드: <INPUT type="button" value="execCommand('saveAs') 예제" onclick="document.execCommand('saveAs')">
결과:
focus 메서드
IE5 NS6
⇒ 개체가 초점을 받고
onfocus 이벤트에서 지정한 코드를 수행한다.
문법: documentObj .focus()
코드: self.focus();document.write(document.activeElement.nodeName)
결과: INPUT
getElementById 메서드
IE5 NS6
⇒
id 에 의하여 엘레맨트를 참조한다.
문법: documentObj .getElementById(sVal )
코드: document.write(document.getElementById('sampleObj').nodeName)
결과: DIV
코드: document.write(document.getElementById('sampleObj').innerHTML.length)
결과: 85
getElementsByName 메서드
IE5 NS6
⇒
name 에 의하여 엘레맨트 배열변수를 참조한다.
문법: documentObj .getElementsByName(nameString )
코드: <INPUT name=inName value="예제 입력"> <SCRIPT>col=document.getElementsByName('inName');document.write(col[0].nodeName+' | '+col[0].value)</SCRIPT>
결과: INPUT | 예제 입력
getElementsByTagName 메서드
IE5 NS6
⇒ 엘레멘트 명칭으로 엘레맨트 컬렉션을 참조한다.
문법: documentObj .getElementsByTagName(elemName )
코드: document.write(document.getElementsByTagName('div').length)
결과: 187
코드: document.write(document.getElementsByTagName('div')[99].className)
결과: syntax
getSelection 메서드
- NS4
⇒ 현재 문서 속의 선택된 문자열을 반환하는데 사용될 수 있다.
문법: documentObj .getSelection()
handleEvent 메서드
- NS4
⇒ 특정 이벤트의 처리기를 호출하는데 사용된다.
문법: documentObj .handleEvent ('eventID')
hasFocus 메서드
IE
⇒ 개체가 현재 초점을 받았는가를 부울값으로 반환한다.
문법: documentObj .hasFocus()
코드: document.write(document.hasFocus())
결과: true
mergeAttributes 메서드
IE5 NS6
⇒ 엘레멘트의 읽기/쓰기 속성들을 지정한 엘레맨트로 복사한다.
문법: documentObj .mergeAttributes(elemName )
코드: newObj=document.createElement('div');newObj.mergeAttributes(sampleObj);document.write(newObj.attributes.length))
결과:
open 메서드
IE3.02 NS2
⇒
write 와
writeln 메서드들부터의 출력을 수집하기 시작하기 위해 문서(document)을 연다. 이 경우
url 과
name 두 파라메터만 사용된다.
추가적인 파라메터가 제공되면
window .
open 메서드로
window 개체를 연다.
문법: documentObj .open ([ 'mimeType'[ ,'replace']] )
queryCommandEnabled 메서드
IE4 -
⇒
document 개체의 지정한 명령(
commandId )을
execCommand 메서드를 통하여 수행할 수 있는가를 반환한다.
문법: documentObj .queryCommandEnabled(commandId )
코드: document.write(document.queryCommandEnabled('saveAs'))
결과: false
queryCommandIndeterm 메서드
IE4 -
⇒
document 개체의 명령(
commandId ) 수행에서 Indeterm 상태로 반환되는가를 부울값으로 반환한다.
false 이면 이진수(binary)로 반환한다.
문법: documentObj .queryCommandIndeterm(commandId )
코드: document.write(document.queryCommandIndeterm('saveAs'))
결과: false
queryCommandState 메서드
IE4 -
⇒
document 개체의 지정한 명령(
commandId )의 수행이 되었는가를 부울값으로 반환한다.
true 이면 현재 선택된 명령이 이미 수행되었다.
문법: documentObj .queryCommandState(commandId )
코드: document.write(document.queryCommandState('saveAs'))
결과: false
queryCommandSupported 메서드
IE4 -
⇒
document 개체의 지정한 명령(
commandId )의 지원 여부를 부울값으로 반환한다.
문법: documentObj .queryCommandSupported(commandId )
코드: document.write(document.queryCommandSupported('saveAs'))
결과: false
queryCommandText 메서드
IE4 -
⇒
document 개체의 지정한 명령(
commandId ) 수행의 결과값을 문자열로 반환한다.
문법: documentObj .queryCommandText(commandId )
코드: document.write(document.queryCommandText('createLink'))
결과:
queryCommandValue 메서드
IE4 -
⇒
document 개체의 지정한 명령(
commandId ) 수행의 결과값을 반환한다.
문법: documentObj .qqueryCommandValue(commandId )
코드: document.write(document.queryCommandValue('saveAs'))
결과:
recalc 메서드
IE5 -
⇒
document ,
form 개체의 모든 탄력적 속성들의 계산을 실시하여 업데이트한다. 반환값은 없다.
문법: documentObj .recalc()
코드: document.write(document.recalc())
결과: // 반환값은 없다.
releaseCapture 메서드
IE
⇒ 현재 문서에서 마우스이벤트를 제거한다.
문법: documentObj .releaseCapture()
코드: document.write(document.releaseCapture())
결과: // 반환값은 없다.
releaseEvents 메서드
- NS4
⇒
document 개체의 지정된 타입(
eventType )의 캡쳐되어 이벤트를 해제하고 이벤트 개체의 하부 체계로 보낸다.
문법: documentObj .releaseEvents('eventType' )
routeEvent 메서드
- NS4
⇒ 캡쳐된 이벤트를 윈도우 이벤트체계 밑에 추가한다.
이벤트를 윈도우(문서나 layer) 원래 개체에 전달하는데, 목표 개체가 윈도우의 하층개체이면 그 하층개체에 전달한다.
문법: documentObj .routeEvent('event' )
setActive 메서드
IE
⇒ 개체에 초점을 주지 않고 개체를 활성화 시킨다.
문법: documentObj .setActive()
코드: document.write(document.setActive())
결과: // 반환값은 없다.
write 메서드
IE3.02 NS2
⇒ 지정된
document 개체에 HTML 표현을 할 수 있게 한다.
문법: documentObj .write ('expression(s)')
코드: document.write('<IMG src=../../gif/rfproperty.gif>')
결과:
writeln 메서드
IE3.02 NS2
⇒ 지정된 표현 다음에 새로은 라인이 기록되는 것 이외에는 위
write 메서드와 동일하다.
문법: documentObj .writeln ('expression(s)')
코드: document.writeln('<IMG src=../../gif/rfproperty.gif>')
결과:
이벤트 설명
onactivate
엘레멘트 개체가 activeElement 속성으로 설정되면 발생한다.
onbeforeactivate
IE6 엘레멘트 개체가 activeElement 속성으로 설정되기 바로 전에 발생한다.
onbeforecut
문서로 부터 선택한 부분의 잘라내기 하기 바로 전에 원본 개체에 발생한다.
onbeforedeactivate
모체 문서에서 activeElement 속성의 엘레멘트 개체가 현재 개체로 다른 개체로 변경되기 바로 전에 발생한다.
onbeforeeditfocus
편집 가능한 개체가 활성화되거나 편집 가능한 용기에 제어 선택이 이루어 지기 바로 전에 발생한다.
onbeforepaste
시스템 클립보드(잘라낸거나 복사한 내용이 있는 )로부터 문서의 목표개체에 붙여 넣기 바로 전에 발생한다.
onblur
document 개체가 초점을 잃으면 발생되고 지정된 JsCode 를 수행한다.
문법: documentObj .onblur ='JsCode'
onclick
document 개체에서 마우스를 클릭(눌럿다 놓음)하면 발생되고 지정된 JsCode 를 수행한다.
문법: documentObj .onclick ='JsCode'
oncontextmenu
클라이언트 지역에서 오른쪽 마우스 단추를 클릭하였을 때나 콘텍스트(context) 메뉴를 열었을 때 발생
oncontrolselect
사용자가 개체의 제어 선택을 하려고 할 때 발생한다.
oncut
문서의 선택한 내용을 잘라 시스템 클립보드(잘라낸거나 복사한 내용이 있는 )에 넣을 때 원본 개체에 발생
ondblclick
document 개체에서 마우스를 연속 두번 클릭하면 발생되고 지정된 JsCode 를 수행한다.
문법: documentObj .ondblclick ='JsCode'
ondeactivate
모체 문서에서 activeElement 속성의 엘레멘트 개체가 현재 개체로 다른 개체로 변경되면 발생한다.
ondrag
연속 끌기 동작이 진행되는 동안 원본 개체에 발생한다.
ondragend
연속 끌기 동작에서 마우스를 해제하여 진행이 완료되면 원본 개체에 발생한다.
ondragenter
연속 끌기 동작에서 성공적인 끌어 놓기가 완료면 목표 개체에 발생한다.
ondragleave
연속 끌기 동작에서 성공적인 끌어 놓기가 완료되어 목표 개체를 이탈하면 목표 개체에 발생한다.
ondragover
연속 끌기 동작에서 유효한 목표 개체 위에 있는 동안 연속적으로 목표 개체에 발생한다.
ondragstart
연속 끌기 동작에서 선택한 텍스트나 개체를 끌기 시작하면 원본 개체에 발생한다.
ondrop
연속 끌기 동작에서 마우스 단추를 해제하면 목표 개체에 발생한다.
onfocus
document 개체가 초점을 받으면 발생되고 지정된 JsCode 를 수행한다.
문법: documentObj .onfocus ='JsCode'
onfocusin
IE6 엘레맨트에 초점을 조기 바로 전에 엘레멘트에 발생한다.
onfocusout
IE6 다른 엘레맨트로 초점을 이동하면 바로 현재 엘레멘트에 발생한다.
onhelp
활성 윈도우에서 도움말을 위하여 F1 키를 누르면 발생된다.
onkeydown
document 개체에서 자판(key)을 누르면 발생되고 지정된 JsCode 를 수행한다.
문법: documentObj .onkeydown ='JsCode'
onkeypress
document 개체에서 자판(key)을 누르고 있으면 발생되고 지정된 JsCode 를 수행한다.
문법: documentObj .onkeypress ='JsCode'
onkeyup
document 개체에서 자판(key) 누름을 해제하면 발생되고 지정된 JsCode 를 수행한다.
문법: documentObj .onkeyup ='JsCode'
onload
윈도우가 document 개체를 완전히 읽었을 때 발생되며 지정된 JsCode 코드를 수행한다.
문법: documentObj .onload ='JsCode'
onmousedown
document 개체에서 마우스 단추를 눌렀을 때 발생되고 지정된 JsCode 를 수행한다.
문법: documentObj .onmousedown ='JsCode'
onmousemove
마우스 포인터가 개체 위에서 이동하면 발생한다.
onmouseout
마우스 포인터가 개체 밖으로 이동하면 발생한다.
onmouseover
마우스 포인터가 개체 위로 이동하면 발생한다.
onmouseup
document 개체에서 단추 누름을 해제하면 발생되고 지정된 JsCode 를 수행한다.
문법: documentObj .onmouseup ='JsCode'
onmousewheel
IE6 마우스 휠(wheel)을 굴리면 발생한다.
onmove
개체가 이동하면 발생한다.
onmoveend
개체의 이동이 중지되면 발생한다.
onmovestart
개체가 이동하기 시작하면 발생한다.
onpaste
시스템 클립보드(잘라낸거나 복사한 내용이 있는 )로부터 문서의 목표개체에 붙여 넣으면 발생한다.
onpropertychange
개체의 속성을 변경발생한다.
onreadystatechange
개체의 준비상태(readyState ) 속성을 변경시키면 발생한다.
onresizeend
제어 섹션에서 개체의 크기 변경이 완료되면 발생한다.
onresizestart
제어 섹션에서 개체의 크기 변경이 시작되면 발생한다.
onselectionchange
문서의 선택된 부분의 상태가 변경되었을 때 발생된다.
onstop
사용자가 중지 단추를 클릭하거나 웹 페이지를 닫을 때 발생한다.
onunload
document 개체에서 이탈하여 다른 곳으로 가면 발생되고 지정된 JsCode 를 수행한다.
문법: documentObj .onunload ='JsCode'
document 개체 예제
document.title=KoXo 자바스크립트 - 개체(object) - *** | document document.charset=EUC-KR document.defaultCharset=undefined document.location=http://koxo.com/lang/js/object/document.html document.vlinkColor= document.body.clientWidth=1264
<SCRIPT>
str='';
if (document.title) str+='document.title='+document.title+'<BR>';
str+='document.charset='+document.charset+'<BR>';
str+='document.defaultCharset='+document.defaultCharset+'<BR>';
str+='document.location='+document.location+'<BR>';
str+='document.vlinkColor='+document.vlinkColor+'<BR>';
str+='document.body.clientWidth='+document.body.clientWidth+'<BR>';
document.write(str);
</SCRIPT>
최종 수정: 07/26/2025 03:15:40 All right reserved 비정상적인 방식으로 프레임없이 페이지에 접속하면 자주 오류가 발생됩니다. 오류가 나면 정상적 접속 으로 시도해 보세요. http://koxo.com/lang/js/object/document.html