开发者

is there compability problem between document.location.href with document.URL?

what is the different between document.location.href with document.URL? is the开发者_运维知识库re compability problem?


From the Mozilla docs:

URL is a replacement for the DOM Level 0 document.location.href property. However, document.location.href is settable, and document.URL is not.

document.location is not part of any standard (DOM Level 0) even though most browsers support it. document.URL is part of the W3C DOM Level 2 specification.


document.location.href is settable, and document.URL is not.


Both Provides the URL of the current document. The value is the same as location.href. The document.URL property evolved as a replacement for document.location to avoid potential confusion (by scripters and JavaScript interpreter engines) between the location object and document.location property. To navigate to another page, it is safest (for cross-browser and backward compatibility) to assign a URL string value to the location.href property, rather than this document-centered property.


since [proper] location object belongs (and, more important, should belong there) to window, yes to document.location, it is a compatibility problem (or, more precise, DOM level 0 quirk).

FAQ entry: http://xkr.us/js/location

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜