文書の番地

文書の番地 (DOM)

[16] 文書には、文書の番地 (document's address) があります。 文書の番地は、通常はその文書の取得元の URL ですが、 スクリプトの操作などにより異なる値となることもあります。

仕様書

document.URL

[4] DOM HTMLFirefox 2.0、Opera 9 では URL 属性読取専用としていますが、 WinIE 6 では値の設定もできます。 location.href のように、与えられた URI遷移します。

[7] url Property (DOMDocument) ( ( 版)) http://msdn.microsoft.com/en-us/library/ms767669(v=vs.85).aspx

document.documentURI

[12] Firefox 2.0 と Opera 9 は documentURI 属性を実装しています。 WinIE 6 は実装していません。

[13] >>12 いずれも、値の設定はできないようです。

実際と異なる URL

[27] 文書の番地は、 navigate で初期値が設定されます。

[14] 文書の番地は、次の場合に実際とは異なる (同じ瞬間に同じ条件で fetch していたとしても同じものが得られない) URL に設定されます。

[26] view-source: も参照。

ワーカーの URL

[19] WorkerGlobalScope オブジェクトは、 URL (url) を持ちます。 その値は URL または null です。初期値は null です。 >>18

[22] この値は run a worker の過程で設定されます。 ワーカースクリプトの実行時点では、 スクリプトURL となっています。

[23] ワーカーのURLには、 WorkerLocation オブジェクトを介してアクセスできます。

[24] ワーカー外から直接アクセスする方法はありません。
[21] 共有ワーカーにはワーカーのURLの他に構築子URLがあります。 ワーカーのURLリダイレクト等を経た最終的な実際の URL で、構築子URLはその前の呼び出し元が指定したURLです。

関連

[17] 環境設定群オブジェクト作成URLは、文書の番地とは違って、 pushState 等により影響されない最初の URL となります。

歴史

[5] [whatwg] Reconcile document.URL and document.documentURI? ( ( 版)) http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2012-January/034377.html

[6] Web Applications 1.0 r7145 sync with dom core ( ( 版)) http://html5.org/tools/web-apps-tracker?from=7144&to=7145

[8] Web Applications 1.0 r7159 Turns out that browsers don't distinguish between the 'document's address' and the 'documents's current address', so we can merge them. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=7158&to=7159

[9] [whatwg] Document's base URI should use the document's *current* address ( ( 版)) http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-June/036504.html

[10] IRC logs: freenode / #whatwg / 20120629 ( ( 版)) http://krijnhoetmer.nl/irc-logs/whatwg/20120629

[11] IRC logs: freenode / #whatwg / 20130117 ( ( 版)) http://krijnhoetmer.nl/irc-logs/whatwg/20130117#l-766

[15] The HTTP Protocol As Implemented In W3 ( 版) http://www.w3.org/Protocols/HTTP/AsImplemented.html

[20] Give workers a base URL and clean up shared workers · whatwg/html@b620471 ( 版) https://github.com/whatwg/html/commit/b620471ff823e8e6507b077cf0785a530762f5e3

[25] Fix #118: clarify documentURI/URL and baseURI return a serialized value · whatwg/dom@b4664d6 ( 版) https://github.com/whatwg/dom/commit/b4664d65f494be62141c85a5efb9c367de8c70bc

[28] Rename document's address to URL ( (annevk著, )) https://github.com/whatwg/html/commit/16dd60cfb1cbd4ea3dcacc91f58b368b021ded33

[29] Use USVString for URLs and origins in IDL ( (zcorpan著, )) https://github.com/whatwg/dom/commit/1bb85a48e07d1000e00bd792d61247b9a5e2e4ae

[30] document.open URL handling is fishy · Issue #3286 · whatwg/html () https://github.com/whatwg/html/issues/3286

[31] document.open() simplifications, part 2 (TimothyGu著, ) https://github.com/whatwg/html/commit/ae7cf0cc1936c6c309d7279c822dffc3af147851

[32] document.open() can make a document's URL go out of sync with its history entry · Issue #3885 · whatwg/html () https://github.com/whatwg/html/issues/3885

[33] document.open() can make a document's URL go out of sync with its history entry · Issue #3885 · whatwg/html () https://github.com/whatwg/html/issues/3885

[34] document.open() simplifications, part 2 by TimothyGu · Pull Request #3946 · whatwg/html () https://github.com/whatwg/html/pull/3946

[35] document.open(): remove fragment before propagating entry document's URL (TimothyGu著, ) https://github.com/whatwg/html/commit/ae688ea9845f145d6a7b31c67e727b56442ceada

[36] Unclear what to do with fragments on document.open · Issue #2555 · whatwg/html () https://github.com/whatwg/html/issues/2555

[37] document.open(): remove fragment before propagating entry document's URL by TimothyGu · Pull Request #3970 · whatwg/html () https://github.com/whatwg/html/pull/3970

[38] Setting the document's address doesn't seem to be correct · Issue #3953 · whatwg/html () https://github.com/whatwg/html/issues/3953

[39] Consider not special casing document's address handling when loading javascript: · Issue #1565 · whatwg/html () https://github.com/whatwg/html/issues/1565

[40] Specify a new document's URL by jyasskin · Pull Request #4205 · whatwg/html () https://github.com/whatwg/html/pull/4205