document对象方法有哪些(document的用法)
document对象:代表整个HTML 文档,可用来访问页面中的所有元素。document对象:代表整个HTML 文档,可用来访问页面中的所有元素。(1)对象属性①document.title 文档标题,等价于HTML的标签②document.bgColor 页面背景色③document.fgColor 前景色(文本颜色)④document.linkColor 未点击过的链接颜色⑤document
document对象:代表整个HTML 文档,可用来访问页面中的所有元素。
(1)对象属性 ①document.title 文档标题,等价于HTML的标签 ②document.bgColor 页面背景色 ③document.fgColor 前景色(文本颜色) ④document.linkColor 未点击过的链接颜色 ⑤document.alinkColor 激活链接(焦点在此链接上)的颜色 ⑥document.vlinkColor 已点击过的链接颜色 ⑦document.URL 在同一窗口打开另一网页 ⑧document.fileCreatedDate 文件建立日期,只读属性 ⑨document.fileModifiedDate 文件修改日期,只读属性 ⑩document.fileSize 大小,只读属性 ⑪document.cookie 设置和读出cookie ⑫document.charset 字符集 (2)对象方法 ①document.write() 动态向页面写入内容 ②document.createElement(tag) 创建指定标签的元素 ③document.getElementById(id) 获得指定id值的元素 ④document.getElementsByName(name) 获得指定Name值的元素 (3)body对象 ①document.body 文档主体开始和结束,等价于 ②document.body.bgColor 背景颜色 ③document.body.link 未点击过的链接颜色 ④document.body.alink 激活链接(焦点在此链接上)的颜色 ⑤document.body.vlink 已点击过的链接颜色 ⑥document.body.text 文本色 ⑦document.body.innerText...之间的文本 ⑧document.body.innerHTML..之间的HTML代码 ⑨document.body.topMargin 页面上边距 ⑩document.body.leftMargin 页面左边距 ⑪document.body.rightMargin 页面右边距 ⑫document.body.bottomMargin 页面下边距 ⑬document.body.background 背景 ⑭document.body.appendChild(oTag) 添加DOM对象 ⑮document.body.onclick="func()" 鼠标指针单击对象是触发 ⑯document.body.onmouseover="func()" 鼠标指针移到对象时触发 ⑰document.body.onmouseout="func()" 鼠标指针移出对象时触发 (4)location-位置子对象 ①document.location.hash #号后的部分 ②document.location.host 域名+端口号 ③document.location.hostname 域名 ④document.location.href 完整URL ⑤document.location.pathname 目录部分 ⑥document.location.port 端口号 ⑦document.location.protocol 网络协议 ⑧document.location.search ?号后的部分 (5)通过集合引用(以images集合为例,forms集合等类似) ①document.images 标签 ②document.images.length 标签的个数 ③document.images[0] 第1个标签 ④document.images[i] 第i-1个标签
document对象:代表整个HTML 文档,可用来访问页面中的所有元素。