JS Window object in detail and page jump

Source: Internet
Author: User

JS Window object in detail and page jump

Transferred from: http://www.makaidong.com/%E5%8D%9A%E5%AE%A2%E5%9B%AD%E6%90%9C/39219.shtml

1.Window.top.window. location = "index.asp";

2.window.top.location.href= "Index.asp"

3. window.top.location.replace ("index.asp");

4. window. Navigate ("index.asp");

5.windows. The Open ()// New Window JS script can access the properties and methods of the previous window with windows.parent pointing to the previous form;

6. window. History.go ( -2);// This is the fastest, read from the local cache. But the page data may not be up to date

History.go (-1),

History.back ().

Window.history.forward ()

... ... Detailed history implementation method see Blog < js page jump and JS open new Window Method > "Http://blog. Macaidong/henry_yqh/article/details/8530711"

------------------------------------

The prefix attribute is interpreted first:

Window : each browser window and window frame are represented by Window objects, and each window in the application creates a Windows object, creating a separate execution environment for JS that contains the important attributes of document

(document display structure), location (address attribute), frames[] (table singular group), history (record), screen, navigator (browser properties), top (outermost frame), parent (upper frame), self, Window (self-referencing property)

PS: The default is his window property; So it should be possible to omit the window keyword, we rarely appear in the use of the window keyword;

Location : The Position property of the window is an object that represents the URL of the currently displayed document;

The href attribute of the Locaiton is a string that contains the full URL, other attributes protocol, host, pathname, and search (? The next part) declares each part of the URL separately, and the value of the direct location is actually taken by its href value, since it has a ToString () method;

A URL string can be copied directly to the Loation object, the role is to cause the browser to load the content of the URL page, but the location object itself is not a method can be replaced by a URL; js After 1.1, there are two methods: Reload () reloads the current interface from webserver, andreplace () loads and displays the specified URL, but instead of calling replace for a given URL and assigning a URL to a window's location , when replace is called, the specified URL replaces the current URL in the browser history.

Instead of creating a new entry in the history list, you may not be able to return to the original document if you use the Back button on the browser.

PS. Personal use found, at least in the Chrome browser, to the location of the assignment and the location of the href assigned value, the implementation is different, to the location assignment, the browser may do more resources to release the action (Specific issues Personal blog:/http Blog. Macaidong/mrvinc/article/details/9733281)

---------------------------------------

There are also some server implementation methods:

Response.Redirect ()
This works by: The client enters the URL, sends a request to the server, accesses the server, and then the server responds with a URL that returns a jump to the client, then browses the redirect (302), sends the request again like the server, and the server responds to the action on request. To achieve this process in the middle of access to two servers, access is time, so this is time-consuming.
The jump method used in the background is actually a little bit less efficient , because it takes two interactions with the server to get to the destination page.

Server.Transfer ()
This works: The client enters the URL, sends a request to the server, accesses the server, and then the server rings to see if you want to access a new URL, jump directly from the server, and return the one you want to display. A server is accessed in the middle, and the address of the browser does not change.

window.showModalDialog () Open Subwindow method;

JS Window object in detail and page jump

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.