window.document

window.document返回当前窗口内的文档节点(document

注: 从Firefox 3和IE7开始,访问其他页面内的文档节点会受到同源策略的影响.

语法

doc = window.document 

参数

  • doc是一个指向document对象的引用

例子

<!DOCTYPE html>
<html>
<head>
   <title>Hello, World!</title>
</head>
<body>

<script type="text/javascript">
   var doc = window.document;
   alert( doc.title);    // 弹出: Hello, World!
</script>

</body>
</html>

规范

Specification Status Comment
HTML Living Standard
Window.document
Living Standard
HTML5
Window.document
Recommendation

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
documentChrome Full support YesEdge Full support 12Firefox Full support YesIE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support  
Full support