views:

42

answers:

1

Hi to all. 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('#')));
}
+1  A: 

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

Nick Craver
Thanks Nick. But if I past it into my .js file it doesn't make what I need...
bobighorus
@bobighorus - You aren't given much context here, when is this running?
Nick Craver