bobighorus
bobighorus

Reputation: 1152

hide url hashtag with jquery

I need the code to hide the hashtag in the url in jQuery; I'm working on a OnePageSite and I wish to obtain "www.mysite.it" and not "www.mysite.it/index.php#hashtag" when clicking on a link. This is a piece of code for Mootools 1.x; is there a way to make the same with jQuery? Thank you in advance. Best regards.

if(window.location.href.indexOf('#')>-1) {
  window.location.replace(window.location.href.substr(0,window.location.href.indexOf('#')));
}

Upvotes: 0

Views: 1091

Answers (1)

Nick Craver
Nick Craver

Reputation: 630389

That code is JavaScript and not at all dependent on any MooTools functions, you can use it with (or without) any framework.

Upvotes: 1

Related Questions