Details about window. location, window. location

Source: Internet
Author: User

Details about window. location, window. location

Properties of the window. location object

Hash // The URL (Anchor) starting from)

Host // host name and port number of the current URL

Hostname // host name of the current URL

Href // complete URL

Pathname // the path of the current URL

Port // The port number of the current URL

Protocol // protocol of the current URL

Search // question mark (?) Start URL

To use JS to locate the anchor, you can use window. hash with the element ID.

You can use window. location. search to capture the parameters requested by page get in JS, and then use the split method in combination with loop traversal to freely organize the data format.


What is windowtoplocation used? You can not give a detailed explanation. It is better to give an example,

Is the address object of your top-level webpage page.
For example, the location. href of the page that Baidu knows is
Zhidao.baidu.com/question/88553493.html

Location is an object that includes the address mentioned above. There are some other methods,
For example, replace (replace address), and attributes such as href (address)

As for top, it indicates a top-level page, because the page may be embedded with sub-pages such as frame, top indicates the outermost layer.

Windowlocation = url + "? Id = "+ id is what, especially + "? Id = "why is there a + id?

Window. location = This is followed by a string, where "? Id = "indicates the parameter name" id ". To add a value to the parameter name" id ", connect with the" + ". The variable id is the specific value to be included.
For example:
Var url = "abc. jsp ";
Var id = "123 ";
Window. location = url + "? Id = "+ id ---> resolved to window. location =" abc. jsp? Id = 123 ";

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.