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