开发者

hide url hashtag with jquery

开发者 https://www.devze.com 2023-01-19 11:31 出处:网络
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 \"ww开发者_StackOverflow中文版w.mysite.it/index.php#hashtag\" whe

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 "ww开发者_StackOverflow中文版w.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('#')));
}


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

0

精彩评论

暂无评论...
验证码 换一张
取 消