How do you obtain the anchor part of a URL in JavaScript? -


How to obtain the anchor part of the URL after the # in JavaScript? To get the "anchor part" of the current page, you can use it:

/ P >

  var hash = window.location.hash; After that, based on your question link, you want to send it to PHP scripts. You can do this with a JavaScript redirect like:  
  window.location = "myscript.php? Hash =" + encodeurIComponent (hash);  

However, this will not work for users without JavaScript enabled, so make sure & lt; Noscript & gt; Message ready!


Comments