SYNCERのロゴ
アイキャッチ画像

Window.document - ドキュメント

documentは、Windowのプロパティです。このウィンドウが参照しているDocumentを返します。普段、document.getElementById()のようにメソッドやプロパティを利用してるのは、window.document.getElementById()のwindowを省略している形です。

概要

名前
document
所属
Window
IDL
[Unforgeable] readonly attribute Document document;
仕様書
https://html.spec.whatwg.org/multipage/window-object.html#dom-document-2

説明

参照しているDocumentを返す。

デモ

Window.documentのデモです。

<!-- このコードは編集できます。 -->

<!DOCTYPE html>
<html>
<head>
<style>
body { word-break: break-all ; }
div#result { white-space: pre-wrap ; }
</style>
</head>
<body>
<div id="result"></div>
<script>
var resultElement = document.getElementById( "result" ) ;

var value = window.document ;

console.log( value ) ;
resultElement.textContent = value ;
</script>

</body>
</html>

サポート状況

ChromeFirefoxSafariEdgeIEOperaiOS SafariAndroid
  • Twitterでシェア
  • Facebookでシェア
  • Google+でシェア
  • はてなブックマークでシェア
  • pocketに保存
  • LINEでシェア
更新履歴
2017年10月13日 (金)
コンテンツを公開しました。