转自:http://blog.sina.com.cn/s/blog_603d1d740100trt3.html
对象属性
document.title
document.bgColor
document.fgColor
document.linkColor
document.alinkColor
document.vlinkColor
document.URL
document.fileCreatedDate
document.fileModifiedDate
document.fileSize
document.cookie
document.charset
---------------------------------------------------------------------
常用对象方法
document.write()
document.createElement_x(Tag)
document.getElementByIdx_x(ID)
document.getElementsByName(Name)
document.body.appendChild(oTag)
---------------------------------------------------------------------
body-主体子对象
document.body
document.body.bgColor
document.body.link
document.body.alink
document.body.vlink
document.body.text
document.body.innerText
document.body.innerHTML
document.body.topMargin
document.body.leftMargin
document.body.rightMargin
document.body.bottomMargin
document.body.background
document.body.appendChild(oTag) //动态生成一个HTML对象
常用对象事件
document.body.οnclick="func()"
document.body.οnmοuseοver="func()"
document.body.οnmοuseοut="func()"
---------------------------------------------------------------------
location-位置子对象
document.location.hash
document.location.host
document.location.hostname
document.location.href
document.location.pathname
document.location.port
document.location.protocol
document.location.search
documeny.location.reload()
document.location.reload(URL)
document.location.assign(URL)
document.location.replace(URL)
---------------------------------------------------------------------
selection-选区子对象
document.selection
---------------------------------------------------------------------
images集合(页面中的图象)
a)通过集合引用
document.images
document.images.length
document.images[0]
document.images[i]
b)通过nane属性直接引用
<img name="oImage">
document.images.oImage
c)引用图片的src属性
document.images.oImage.src
d)创建一个图象
var oImage
oImage = new Image()
document.images.oImage.src="1.jpg"
同时在页面上建立一个<img>标签与之对应就可以显示
<html>
<img name=oImage>
<script language="javascript">
</script>
</html>
<html>
<script language="javascript">
</script>
</html>
----------------------------------------------------------------------
forms集合(页面中的表单)
a)通过集合引用
document.forms
document.forms.length
document.forms[0]
document.forms[i]
document.forms[i].length
document.forms[i].elements[j]
b)通过标签name属性直接引用
<formname="Myform"><inputname="myctrl"></form>
document.Myform.myctrl
c)访问表单的属性
document.forms[i].name
document.forms[i].action
document.forms[i].encoding
document.forms[i].target
document.forms[i].appendChild(oTag) //动态插入一个控件
-----------------------------------------------------------------------
<html>
<!--Text控件相关Script-->
<form name="Myform">
<input type="text"name="oText">
<input type="password"name="oPswd">
<form>
<script language="javascript">
//获取文本密码框的值
document.write(document.Myform.oText.value)
document.write(document.Myform.oPswd.value)
</script>
</html>
-----------------------------------------------------------------------
<html>
<!--checkbox,radio控件相关script-->
<form name="Myform">
<input type="checkbox" name="chk"value="1">1
<input type="checkbox" name="chk"value="2">2
</form>
<scriptlanguage="javascript">
functionfun(){
</script>
<a href=#οnclick="fun()">ddd</a>
</html>
-----------------------------------------------------------------------
<html>
<!--Select控件相关Script-->
<form name="Myform">
<select name="oSelect">
<optionvalue="1">1</option>
<optionvalue="2">2</option>
<optionvalue="3">3</option>
</select>
</form>
<scriptlanguage="javascript">
</script>
<scriptlanguage="javascript">
</script>
<scriptlanguage="javascript">
</script>
<scriptlanguage="javascript">
</script>
<html>
-----------------------------------------------------------------------
<Divid="oDiv">Text</Div>
document.all.oDiv
document.all.oDiv.style.display=""
document.all.oDiv.style.display="none"
document.getElementId("oDiv")
document.getElementId("oDiv").style=""
document.getElementId("oDiv").display="none"
图层对象的4个属性
document.getElementByIdx_x("ID").innerText
document.getElementByIdx_x("ID").innerHTML
document.getElementByIdx_x("ID").outerText
document.getElementByIdx_x("ID").outerHTML
<html>
<script language="javascript">
function change(){
document.all.oDiv.style.display="none"
}
</script>
<Div id="oDiv"οnclick="change()">Text</Div>
</html>
<html>
<script language="javascript">
function changeText(){
document.getElementByIdx_x("oDiv").innerText="NewText"
}
</script>
<Div id="oDiv"οnmοuseοver="changeText()">Text</Div>
</html>