Home > Article > Web Front-end > js gets current page path example explanation_javascript skills
Set or get the "file name" or path specified by the object.
<script><br>alert(window.location.pathname)<br></script>
Set or get the entire URL as a string.
<script><br>alert(window.location.href); <br></script>
Set or get the port number associated with the URL.
<script><br>alert(window.location.port)<br></script>
Set or get the protocol part of the URL.
<script><br>alert(window.location.protocol)<br></script>
Set or get the segment after the pound sign "#" in the href attribute.
<script><br>alert(window.location.hash)<br></script>
Set or get the hostname and port number of location or URL.
<script><br>alert(window.location.host)<br></script>
Sets or gets the part of the href attribute that follows the question mark.
<script><br>alert(window.location.search)<br></script>
Web page refresh recommendation-JS