js Document 对象属性和方法

document.writeln() 等同于 write() 方法,不同的是在每个表达式之后写一个换行符。
document.scripts 返回页面中所有脚本的集合。
document.title 返回当前文档的标题。
document.URL 返回文档完整的URL
document.referrer 返回载入当前文档的文档的 URL。
document.querySelector() 返回文档中匹配指定的CSS选择器的第一元素
document.querySelectorAll() document.querySelectorAll() 是 HTML5中引入的新方法,返回文档中匹配的CSS选择器的所有元素节点列表
document.readyState 返回文档状态 (载入中……)
document.normalize() 删除空文本节点,并连接相邻节点
document.links 返回对文档中所有 Area 和 Link 对象引用。links 集合计算 <a href=""> 标签和 <area> 标签。
document.inputEncoding 返回用于文档的编码方式(在解析时)。(ie8不支持)
document.lastModified 返回文档被最后修改的日期和时间。
document.importNode(node,deep) 把一个节点从另一个文档复制到该文档以便应用。(ie8不支持)
document.images 返回对文档中所有 Image 对象引用。
document.forms 返回对文档中所有 Form 对象引用。
document.getElementsByClassName() 返回文档中所有指定类名的元素集合,作为 NodeList 对象。(ie8不支持
document.documentElement 返回文档的根节点
document.documentMode 返回用于通过浏览器渲染文档的模式,只支持ie
document.domain 返回当前文档的域名。)
document.cookie 设置或返回与当前文档有关的所有 cookie。
document.createAttribute() 创建一个属性节点
document.createComment() createComment() 方法可创建注释节点。
document.createElement() 创建元素节点。
document.createTextNode() 创建文本节点。
document.doctype 返回与文档相关的文档类型声明 (DTD)。
document.adoptNode(node) 从另外一个文档返回 adapded 节点到当前文档。adoptNode() 方法用于从另外一个文档中获取一个节点。
节点可以是任何节点类型。
注意: 节点下的所有子节点都会获取到。
注意: 节点及其子节点会再源文档中删除。
提示: 使用 document.importNode() 方法来拷贝节点,但原文档中的节点不删除。.
提示: 使用 element.cloneNode() 方法来拷贝当前文档的节点,且节点不会被删除。
document.anchors 返回对文档中所有 Anchor 对象的引用。a标签包括name属性
document.activeElement 返回当前获取焦点元素

       if (document.removeEventListener) {         // 所有浏览器,除了 IE 8 及更早IE版本
            document.removeEventListener("mousemove", myFunction);
            //document.addEventListener("mousemove",myFunction)
        } else if (document.detachEvent) {         // IE 8 及更早IE版本
            document.detachEvent("onmousemove", myFunction);
            document.attachEvent("onmousemove", myFunction)
        }

猜你喜欢

转载自blog.csdn.net/qwe435541908/article/details/84847737