Details about the usage and function of window. location. search in js, and the usage of window. location

Source: Internet
Author: User

Details about the usage and function of window. location. search in js, and the usage of window. location

Use this property to obtain the URL of the page:

Properties of the window. location object

Attribute Description
Hash 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 Path section of the current URL
Port Port Number of the current URL
Protocol Protocol of the current URL
Search From Question mark (?) Start URL (query part)

Is to retrieve the parameters in the url.

What are the parameters requested by the GET method on the page captured by the JS script? In fact, you can directly use window. location. search to obtain the data format, and then use the split method to traverse the data format in a loop.

The approximate processing is as follows:

var searchURL = window.location.search;searchURL = searchURL.substring(1, searchURL.length);var targetPageId = searchURL.split("&")[0].split("=")[1];

The usage and function of window. location. search in js is shared with all the content in the editor. I hope to give you a reference and support for the customer's house.

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.