1, assume the current page full address is: http://localhost:61768/Home/Index?id=2
//gets the URL of the current windowvarURL =window.location.href;//Results:http://localhost: 61768/home/index?id=2//gets the host name of the current windowvarHost =Window.location.host;//results: localhost:61768//gets the port of the current windowvarPort =Window.location.port;//results: 61768//gets the path of the current windowvarpathname =Window.location.pathname;//results:/home/index//gets the URL of the current documentvarURL =document. URL;//Results:http://localhost: 61768/home/index?id=2//Get ParametersvarSearch =Window.location.search;//results:? id=2
2. Jump out of the current window
// jump out of the current window and open a new window window.open ("http://www.baidu.com");
3. Document and Window
A Document object is implied by the file, and window is the object of a windows, which can have multiple document objects under a window.
So there is only one window.location.href under a window, there may be multiple document.url, document.location.href
Window.location.href and Document.location.href can be assigned, and then jump to other pages, document. URLs can only be read and cannot be assigned values.
Related article:C # request get URL
JavaScript gets the current URL path