JavaScipt的Document对象属性集合
2014-12-12 15:04
85 查看
一、对象属性
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 //设置和读出cookie
document.charset //设置字符集 简体中文:gb2312
二、对象方法
document.write() //动态向页面写入内容
document.open() //打开网页。
document.close() //关闭网页
document.body //指定文档主体的开始和结束
document.body.bgColor//设置或获取对象后面的背景颜色
document.body.link //未点击过的链接颜色
document.body.alink //激活链接(焦点在此链接上)的颜色
document.body.vlink //已点击过的链接颜色
document.body.text //文本色
document.body.innerText //设置body>…/body>之间的文本
document.body.topMargin //页面上边距
document.body.leftMargin //页面左边距
document.body.rightMargin //页面右边距
document.body.bottomMargin //页面下边距
document.body.background //背景图片
三、image属性
a)通过集合引用
document.images //对应页面上的img标签
document.images.length //对应页面上img标签的个数
document.images[0] //第1个img标签
document.images[i] //第i-1个img标签
b)通过nane属性直接引用
imgname=”oImage”
document.images.oImage //document.images.name属性
c)引用图片的src属性
document.images.oImage.src //document.images.name属性.src
d)创建一个图象
var oImage
oImage = newImage()
document.images.oImage.src=”1.jpg”
同时在页面上建立一个img /标签与之对应就可以显示
四、form表单
a)通过集合引用
document.forms //对应页面上的form标签
document.forms.length //对应页面上/form标签的个数
document.forms[0] //第1个/form标签
document.forms[i] //第i-1个/form标签
document.forms[i].length //第i-1个/form中的控件数
document.forms[i].elements[j] //第i-1个/form中第j-1个控件
b)通过标签name属性直接引用
document.Myform.myctrl //document.表单名.控件名
c)访问表单的属性
document.forms[i].name //对应form name>属性
document.forms[i].action //对应/form action>属性
document.forms[i].encoding //对应/form enctype>属性
document.forms[i].target //对应/form target>属性
document.forms[i].appendChild(oTag) //动态插入一个控件
document.all.oDiv //引用图层oDiv
document.all.oDiv.style.display= //图层设置为可视
document.all.oDiv.style.display=”none” //图层设置为隐藏
document.getElementId(”oDiv”) //通过getElementId引用对象
/*document.all表示document中所有对象的集合,只有IE支持此属性,因此也用来判断浏览器的种类*/
五、层对象
document.getElementById(”ID”).innerText //动态输出文本
document.getElementById(”ID”).innerHTML //动态输出HTML
document.getElementById(”ID”).outerText //同innerText
document.getElementById(”ID”).outerHTML //同innerHTML
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 //设置和读出cookie
document.charset //设置字符集 简体中文:gb2312
二、对象方法
document.write() //动态向页面写入内容
document.open() //打开网页。
document.close() //关闭网页
document.body //指定文档主体的开始和结束
document.body.bgColor//设置或获取对象后面的背景颜色
document.body.link //未点击过的链接颜色
document.body.alink //激活链接(焦点在此链接上)的颜色
document.body.vlink //已点击过的链接颜色
document.body.text //文本色
document.body.innerText //设置body>…/body>之间的文本
document.body.topMargin //页面上边距
document.body.leftMargin //页面左边距
document.body.rightMargin //页面右边距
document.body.bottomMargin //页面下边距
document.body.background //背景图片
三、image属性
a)通过集合引用
document.images //对应页面上的img标签
document.images.length //对应页面上img标签的个数
document.images[0] //第1个img标签
document.images[i] //第i-1个img标签
b)通过nane属性直接引用
imgname=”oImage”
document.images.oImage //document.images.name属性
c)引用图片的src属性
document.images.oImage.src //document.images.name属性.src
d)创建一个图象
var oImage
oImage = newImage()
document.images.oImage.src=”1.jpg”
同时在页面上建立一个img /标签与之对应就可以显示
四、form表单
a)通过集合引用
document.forms //对应页面上的form标签
document.forms.length //对应页面上/form标签的个数
document.forms[0] //第1个/form标签
document.forms[i] //第i-1个/form标签
document.forms[i].length //第i-1个/form中的控件数
document.forms[i].elements[j] //第i-1个/form中第j-1个控件
b)通过标签name属性直接引用
document.Myform.myctrl //document.表单名.控件名
c)访问表单的属性
document.forms[i].name //对应form name>属性
document.forms[i].action //对应/form action>属性
document.forms[i].encoding //对应/form enctype>属性
document.forms[i].target //对应/form target>属性
document.forms[i].appendChild(oTag) //动态插入一个控件
document.all.oDiv //引用图层oDiv
document.all.oDiv.style.display= //图层设置为可视
document.all.oDiv.style.display=”none” //图层设置为隐藏
document.getElementId(”oDiv”) //通过getElementId引用对象
/*document.all表示document中所有对象的集合,只有IE支持此属性,因此也用来判断浏览器的种类*/
五、层对象
document.getElementById(”ID”).innerText //动态输出文本
document.getElementById(”ID”).innerHTML //动态输出HTML
document.getElementById(”ID”).outerText //同innerText
document.getElementById(”ID”).outerHTML //同innerHTML
相关文章推荐
- document对象的集合属性
- document 对象属性集合
- JavaScript HTML DOM节点类型之Document类型(Document对象属性和Document对象集合属性)
- 自定义UserControl中包含封装了集合对象的属性被设计器自动初始化所引起的错误
- Javascript的document对象的属性应用
- [.NET 3.x新特性一]自动属性,对象初始化及集合初始化
- 建立可对任意属性排序的对象集合
- [.NET 3.x新特性一]自动属性,对象初始化及集合初始化
- UserControl 中包含封装了集合对象的属性被设计器自动初始化所引起的错误!也有关于List的问题
- JAVA中根据集合中对象属性排序的方法
- UserControl 中包含封装了集合对象的属性被设计器自动初始化所引起的错误!也有关于List的问题
- 3、步步为营VS 2008 + .NET 3.5(3) - C# 3.0新特性之Automatic Properties(自动属性)、Object Initializers(对象初始化器)、Collection Initializers(集合初始化器)和Extension Methods(扩展方法)
- javascript的Document对象——属性
- 解决document.form.submit()对象不支持此属性或方法
- document对象的属性
- document对象属性
- 获得文档信息(document对象的几个属性)
- document对象的属性和方法
- masterpage中服务器端控件命名规则和如何用控件名取得document中的对象,用js动态设置控件事件和属性
- 浏览器对象之遍历window的属性,document.write类似于response.write