JS 之document常用方法属性事件
来源:互联网 发布:恢复系统数据 编辑:程序博客网 时间:2024/05/16 17:25
转自: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.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.onclick="func()"
document.body.onmouseover="func()"
document.body.onmouseout="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=#onclick="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"onclick="change()">Text</Div>
</html>
<html>
<script language="javascript">
function changeText(){
document.getElementByIdx_x("oDiv").innerText="NewText"
}
</script>
<Div id="oDiv"onmouseover="changeText()">Text</Div>
</html>
- JS 之document常用方法属性事件
- JS的Document属性和常用方法
- js document常用的属性以及方法
- js基础之DOM中document对象的常用属性方法
- JS中Window,document,form的属性,方法,事件
- Js window.document 的属性、方法和事件汇总
- 【转】Js window.document 的属性、方法和事件汇总
- JS中Window,document,form的属性,方法,事件(转)
- document 常用方法和事件
- Window、document、form(属性、方法、事件)
- Window、document、form(属性、方法、事件)
- Window、document、form(属性、方法、事件)
- Window、document、form(属性、方法、事件)
- Window、document、form(属性、方法、事件)
- Window、document、form(属性、方法、事件)
- JS的Document属性和方法 (抄)
- JS的Document属性和方法 (抄)
- JS的Document属性和方法
- Ubuntu vim 配置以及快捷键使用
- Android -----基于回调机制的事件处理
- MC药水合成
- hdu1754(线段数维护区间最大值)
- eclipse断点调试
- JS 之document常用方法属性事件
- Debug Assertion Failed filecore.cpp line258
- 在spring security手动 自定义 用户认证 SecurityContextHolder
- 黑马程序员Java基础(1)
- 浮点数据(float/double)在计算机上的存储方式
- 无插件Vim编程技巧
- MinGW与Cygwin
- java中SQL的批处理
- vb.net datagridview 使用方法