객체 속성
코드 사본은 다음과 같습니다.
Document.title // html과 동등한 <title> 태그를 설정
document.bgcolor // 페이지 배경색을 설정합니다
document.fgcolor // 전경 색상 설정 (텍스트 색상)
document.linkcolor // 깔끔한 링크 색상
document.alinkcolor // 링크의 색상 활성화 (이 링크에 중점을 둡니다)
document.vlinkcolor // 링크 색상을 클릭하십시오
document.url // 같은 창에서 다른 웹 페이지를 열도록 URL 속성 설정
document.fileCreatedDate // 파일 생성 날짜, 읽기 전용 속성
document.fileModifiedDate // 파일 수정 날짜, 읽기 전용 속성
document.filesize // 파일 크기, 읽기 전용 속성
document.cookie // 쿠키를 설정하고 읽습니다
문서. Charset // 문자 세트 Simplified Chinese : GB2312
============================================================================================================================
바디-개체
코드 사본은 다음과 같습니다.
Boduce.body // 지정된 문서 본문의 시작과 끝은 <body> </body>와 같습니다.
document.body.bgcolor // 객체 뒤에 배경색을 설정하거나 가져옵니다.
document.body.link // 깔끔한 링크 색상
document.body.alink // 링크의 색상 활성화 (이 링크에 중점을 둡니다)
document.body.vlink // 링크 색상을 클릭하십시오
document.body.text // 텍스트 색상
document.body.innertext // <body> ... </body> 사이에 텍스트를 설정합니다
document.body.innerhtml // <body> ... </body> 사이에 html 코드를 설정합니다
document.body.topmargin // 페이지 마진
document.body.leftmargin // 페이지 왼쪽 여백
document.body.rightmargin // 페이지 오른쪽 여백
document.body.bottommargin // 페이지의 여백
document.body.bothern.background // 배경 사진
document.body.appendChild (OTAG) // HTML 객체를 동적으로 생성합니다
일반적인 객체 이벤트
코드 사본은 다음과 같습니다.
document.body.onclick = "func ()"// 마우스 포인터가 객체가 트리거됩니다
document.body.onmouseover = "func ()"// 마우스 포인터가 객체로 이동할 때 플래시되었습니다.
document.body.onmouseout = "func ()"// 마우스 포인터가 객체 밖으로 이동했을 때 플래시가 깜박입니다.
============================================================================================================================
위치 위치 하위 목체
코드 사본은 다음과 같습니다.
document.location.hash // 숫자 # 이후의 부분
document.location.host // 도메인 이름 + 포트 번호
document.location.hostname // 도메인 이름
document.location.href // 완료 URL
document.location.pathname // 디렉토리 부분
Document.Location.port // 포트 번호
document.location.protocol // 네트워크 프로토콜 (http :)
document.location.search // 이후의 부분? 숫자
일반적인 객체 이벤트
코드 사본은 다음과 같습니다.
documenty.location.reload () // 웹 페이지를 새로 고침합니다
document.location.reload (url) // 새 웹 페이지를 엽니 다
document.location.assign (url) // 새 웹 페이지를 엽니 다
document.location.replace (url) // 새 웹 페이지를 엽니 다
============================================================================================================================
이미지 수집 (페이지의 이미지)
a) 수집을 통한 참조
코드 사본은 다음과 같습니다.
해당 페이지의 <img> 태그 //
해당 페이지에서 <Img> 태그 번호
document.images [0] // 첫 번째 <Img> 태그
document.images // i-1 <Img> 태그
b) 이름 속성을 통한 직접 참조
코드 사본은 다음과 같습니다.
<img name = "oimage">
document.images.oimage //document.images.name 속성
c) 참조 사진의 SRC 속성
코드 사본은 다음과 같습니다.
document.images.oimage.src //document.images.name attribute.src
d) 이미지를 만듭니다
코드 사본은 다음과 같습니다.
var oimage
oimage = new image ()
document.images.oimage.src = "1.jpg"
동시에 페이지에 <Img> 태그를 작성하면 표시 할 수 있습니다.
샘플 코드 (동적 생성) :
코드 사본은 다음과 같습니다.
<html>
<img name = oimage>
<script language = "javaScript">
var oimage
oimage = new image ()
document.images.oimage.src = "1.jpg"
</스크립트>
</html>
<html>
<script language = "javaScript">
oimage = document.caeateelement ( "IMG")
oimage.src = "1.jpg"
document.body.appendchild (oimage)
</스크립트>
</html>
=========================================================================================================
양식 수집 (페이지 양식)
a) 수집을 통한 참조
코드 사본은 다음과 같습니다.
해당 페이지의 <form> 태그 // worms.forms //
document.forms.length // 해당 페이지의 <form> 태그 번호
document.forms [0] // 첫 번째 <FORM> 태그
document.forms // i-1 <form> 태그
document.forms.length // i-1th <form>의 컨트롤 수
document.forms.elements [j] // i-1th <form>의 J-1ST 제어
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------.
b) 태그 이름 속성을 통한 직접 참조
코드 사본은 다음과 같습니다.
<form name = "myform"> <input name = "myctrl"> </form>
document.myctrl //document.form name.control name
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------.
c) 액세스 양식 특성
코드 사본은 다음과 같습니다.
document.forms.name // <양식 이름> 속성에 해당합니다
document.forms.action // <양식 동작> 속성에 해당합니다
document.forms.encoding // <form enctype> 속성에 해당합니다
document.forms.target // <양식 대상> 속성에 해당합니다
document.forms.appendChild (OTAG) // 컨트롤을 동적으로 삽입하십시오
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------.
샘플 코드 (양식) :
코드 사본은 다음과 같습니다.
<html>
<!-텍스트 제어 관련 스크립트->
<form name = "myform">
<입력 유형 = "텍스트"이름 = "otext">
<입력 유형 = "password"name = "opswd">
<양식>
<script language = "javaScript">
// 텍스트 비밀번호 상자의 값을 얻습니다
document.write (document.myform.otext.value)
document.write (document.myform.opswd.value)
</스크립트>
</html>
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------.
샘플 코드 (확인란) :
코드 사본은 다음과 같습니다.
<html>
<!-확인란, 무선 제어 관련 스크립트->
<form name = "myform">
<input type = "checkbox"name = "chk"value = "1"> 1
<입력 유형 = "checkbox"name = "chk"value = "2"> 2
</form>
<script language = "javaScript">
기능 fun () {
// 확인란 제어 값을 전송하고 선택한 지 확인
var 길이
길이 = document.forms [0] .chk.length
for (i = 0; i <길이; i ++) {
v = document.forms [0] .CHK.Value
b = document.forms [0] .CHK.CHECKED
if (b)
경고 (v = v+"selected")
또 다른
경고 (v = v+"선택되지 않은")
}
}
</스크립트>
<a href =# onclick = "fun ()"> ddd </a>
</html>
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------.
샘플 코드 (선택) :
코드 사본은 다음과 같습니다.
<html>
<!-제어 관련 스크립트를 선택하십시오->
<form name = "myform">
<이름을 선택하십시오 = "Oselect">
<옵션 값 = "1"> 1 </옵션>
<옵션 값 = "2"> 2 </옵션>
<옵션 값 = "3"> 3 </옵션>
</선택>
</form>
<script language = "javaScript">
// 선택 컨트롤의 옵션 항목을 전송합니다
var 길이
길이 = document.myform.oselect.length
for (i = 0; i <길이; i ++)
document.write (document.myform.oselect.value)
</스크립트>
<script language = "javaScript">
// 옵션 항목을 전송하고 옵션이 선택되었는지 여부를 결정합니다.
for (i = 0; i <document.myform.oselect.length; i ++) {
if (document.myform.oselect.selected! = true)
document.write (document.myform.oselect.value)
또 다른
document.write ( "<font color = red>"+document.myform.oselect.value+"</font>")
}
</스크립트>
<script language = "javaScript">
// selectedIndex에 따라 선택된 옵션을 인쇄합니다
// (0 to document.myform.oselect.length-1)
i = document.myform.oselect.selectedIndex
document.write (document.myform.oselect.value)
</스크립트>
<script language = "javaScript">
// 선택 컨트롤의 옵션 항목을 동적으로 증가시킵니다.
var ooption = document.createElement ( "옵션");
oooption.text = "4";
oooption.value = "4";
document.myform.oselect.add (ooption);
</스크립트>
<html>
============================================================================================================================
div 컬렉션 (페이지 계층)
코드 사본은 다음과 같습니다.
<div id = "odiv"> 텍스트 </div>
document.all.odiv // 참조 계층 Odiv
document.all.odiv.style.display = ""// 레이어가 Visual으로 설정됩니다
document.all.odiv.style.display = "none"// 레이어가 숨길 수 있습니다
getElementID를 통한 oxpert.getElementId ( "Odiv") // 객체를 참조하십시오
document.getElementId ( "odiv").
document.getElementId ( "odiv"). display = "none"
/* document.all 문서의 모든 개체 모음을 나타냅니다.
IE만이 속성을 지원하므로 브라우저의 유형을 결정하는 데에도 사용됩니다.
4 층 객체의 속성
코드 사본은 다음과 같습니다.
document.getElementById ( "id"). 내부 텍스트 // 동적 출력 텍스트
document.getElementById ( "id"). InnerHtml // 동적 출력 html
document.getElementById ( "id"). outertext // 동일한 내부 텍스트
document.getElementById ( "id"). auterhtml // innerhtml과 동일합니다
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------.
샘플 코드 :
코드 사본은 다음과 같습니다.
<html>
<script language = "javaScript">
함수 변경 () {
document.all.odiv.style.display = "none"
}
</스크립트>
<div id = "odiv"onclick = "Change ()"> 텍스트 </div>
</html>
<html>
<script language = "javaScript">
함수 changetext () {
document.getElementById ( "odiv"). innerText = "newText"
}
</스크립트>
<div id = "odiv"onmouseover = "changetext ()"> text </div>
</html>