document

document document *
*前のトピック: DL
*次のトピック: DT

document

解説

ブラウザウィンドウ内のHTMLドキュメントを表す。

注意事項

ドキュメントの情報を読み出すために、documentオブジェクトを使う。例えば、ドキュメント内のHTMLエレメントやテキストを調べたり編集したりできる。また、イベントを処理することもできる。

documentオブジェクトはいつでもアクセス可能である。windowオブジェクトやエレメントオブジェクトに対してdocumentプロパティを適用することにより、オブジェクトを読み出すことができる。ドキュメントを自分自身に適用した場合、documentは現在のウィンドウのドキュメントを表すことになる。

次の例では、ドキュメントのタイトルをチェックし、アラートボックスにそれを表示している(タイトルがnullでない場合)。

if (document.title!="")
alert("The title is " + document.title)

次は、マウスの現在の位置をブラウザのステータスバーに表示するイベントハンドラ関数を表している(座標はドキュメントの左上を原点としている。)。

<HTML>
<HEAD><TITLE>Report mouse moves</TITLE>
<SCRIPT LANGUAGE="JScript">
function reportMove() {
window.status = "X=" + window.event.x + " Y=" + window.event.y;
}
</SCRIPT>
<BODY onmousemove="reportMove()">
<H1>Welcome!</H1>
</BODY>
</HTML>

プロパティ

activeElement, alinkColor, bgColor, body, charset, cookie, defaultCharset, domain, expando, fgColor, lastModified, linkColor, location, parentWindow, readyState, referrer, selection, title, URL, vlinkColor

コレクション

all, anchors, applets, children, embeds, forms, frames, images, links, plugins, scripts, styleSheets

メソッド

clear, close, createElement, createStyleSheet, elementFromPoint, execCommand, open, queryCommandEnabled, queryCommandIndeterm, queryCommandState, queryCommandSupported, queryCommandText, queryCommandValue, ShowHelp, write, writeln

イベント

onafterupdate, onbeforeupdate, onclick, ondblclick, ondragstart, onerrorupdate, onhelp, onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, onreadystatechange, onrowenter, onrowexit, onselectstart

Up トップに戻る
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.