Posted By

sircambridge on 10/27/08


Tagged

javascriptgetSetURLHash


Versions (?)

get/Set URL hash


 / Published in: Other
 

  1. var getHashFromURL = function() {
  2. var r = window.location.href;
  3. var i = r.indexOf("#");
  4. return (i >= 0 ? r.substr(i+1) : "");
  5. };
  6. var setURLHash = function(newhash) {
  7. var url = window.location.href;
  8. url = (!url.match('#'))?url+'#':url.substr(0,url.indexOf('#')+1);
  9. window.location.href = url+newhash;
  10. };

Report this snippet  

You need to login to post a comment.