Javascript-window and document to be sorted

Source: Internet
Author: User

 

Differences between window objects and document objects
Generally, a window is a document. However, a document can also be installed in IFRAME, which is different in IFRAME.

Alert (document. Location = Window. Location ); // True

 

 

Do not confuse the location attribute of the window object with the location attribute of the Document Object. The former references a location object, while the latter is just
The read string does not have any features of the location object. Document. Location is synonymous with document. URL.
Javascript1.1 is the preferred name for this attribute (because this avoids potential confusion ). In most cases, document. Location and
Location. href is the same. However, when server redirection exists, document. location contains the URL that has been loaded, while
Location. href contains the URL of the original request document.

 

What is the difference between document. Location and window. Location?
Document, which is your webpage
Window is understood as a window, which is included by your IE browser.
No framework: Simply put, without a framework, it is equivalent.
Framework: in the case of a framework, the outermost layer is the same. The document. Location and window. Location in IFRAME are different.
The document. Location in IFRAME does not change the IE address. Only the IFRAME part is changed,
At this time, the window. Location and top. location have the same effect.

 

 

document. location = "url"; (read-only)
document. location. reload ("url";);
window. location = "url";
location = "url";
document. href = "url"
document. location. href = "url"
document. location. replace = "url"
document. action = "url"; document. submit ();
document. location. href and document. location. replace can be switched from page a to page B, but the difference is:
use document. location. after the href switch, you can return to the original page. After switching with document. Location. Replace, you cannot return it back to the original page.
about document. location. href or other failover methods
document. location is equivalent to document. the URL declares the URL of the file to be loaded.
unless a server redirection occurs, the value of this attribute corresponds to window. location. the href value is the same.
history. go (-1); // return to the previous page
document. IFRAME name. location. href = 'url'; // modify the framework content

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.