Skip to content

Instantly share code, notes, and snippets.

@arturparkhisenko
Last active September 21, 2015 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arturparkhisenko/af2c95081e6e523dc71d to your computer and use it in GitHub Desktop.
Save arturparkhisenko/af2c95081e6e523dc71d to your computer and use it in GitHub Desktop.
remove hash from url
//source: http://stackoverflow.com/questions/4508574/remove-hash-from-url
//Best is Homero Barbosa's answer below:
history.pushState('', document.title, window.location.pathname);
//... or, if you want to maintain the search parameters:
history.pushState('', document.title, window.location.pathname + window.location.search);
//Old, do not use, badwrongfun:
// var loc = window.location.href,
// index = loc.indexOf('#');
// if (index > 0) {
// window.location = loc.substring(0, index);
// }
//that refreshes the page for you which seems a trifle rude after
//just arriving there. Grin and bear it seems to be the best option.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment