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.