1. Set or get the entire URL as a string:
window.location.href
2. Set or get the port number associated with the URL:
window.location. port
3. Set or get the protocol part of the URL
window.location.protocol
4. Set or get the part following the question mark in the href attribute
window.location.search
5. Get the value of the variable (intercept the part after the equal sign)
var url = window.location.search;
// alert(url.length);
// alert(url.lastIndexOf('= '));
var loc = url.substring(url.lastIndexOf('=') 1, url.length);
6. Set or get the protocol part of the URL:
window.location.protocol
7. Set or get the segment after the hash sign "#" in the href attribute:
window.location.hash
8. Set or get the hostname and port number of location or URL:
window.location.host
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn