Home > UI/UX Development > JavaScript > Javascript window.location.hash

Javascript window.location.hash

Javascript window.location.hash returns the value of URL that comes after “#”

For ex. 
            https://mundrisoft.com/tech-bytes/wp-admin/post-new.php#searchterm

window.location.hash will return “#searchterm” in browsers IE 11, Edge and Chrome  and Mozilla

 

For an empty hash URL:
          https://mundrisoft.com/tech-bytes/wp-admin/post-new.php#

window.location.hash will return
“#” -> Chrome, Mozilla, IE 11
“” -> Edge

So, keep this little trick for browser compatibility in mind next time you are using hash URL. 🙂

This Article is TAGGED in , , , . BOOKMARK THE permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">