Js get the current page path example explained

  • 2020-03-30 01:14:34
  • OfStack

Sets or gets the file name or path specified by the object.
< Script>
Alert (window. The location. The pathname)
< / script>

Sets or gets the entire URL as a string.
< Script>
Alert (window. The location. Href);
< / script>

Sets or gets the port number associated with the URL.
< Script>
Alert (window. The location. The port)
< / script>

Sets or gets the protocol portion of the URL.
< Script>
Alert (window) location) protocol)
< / script>

Sets or gets the section in the href property after the well number "#".
< Script>
Alert (window. The location. The hash)
< / script>

Set or get the hostname and port number of the location or URL.
< Script>
Alert (window. The location. The host)
< / script>

Sets or gets the part of the href attribute that follows the question mark.
< Script>
Alert (window. The location. The search)
< / script>

Page refresh recommendation -JS
< Input type=button value= refresh onclick="history.go(0)">
< Input type=button value= refresh onclick="location.reload()">
< Input type=button value= refresh onclick="location=location">
< Input type=button value= refresh onclick="location.assign(location)">
< Input type=button value= Refresh onclick=" document.execcommand ('Refresh')">
< Input type=button value= refresh onclick="window.navigate(location)">
< Input type=button value= refresh onclick="location.replace(location)">
< Input type=button value= refresh onclick=" document.url =location.href">


Related articles: