开发者

Strip off everything after #anchor including the #anchor

Change this...

www.sample.com/sample.html#commentxxx?stuffhereIdontneed

into this...

www.sample.com/sample.html

I have it in a link so I think I need a regex?

doc开发者_C百科ument.write("<a href='"+ window.location.href.replace('?????', '') +  
"?ThisIsAppendedLater'>sample</a>");  


Nathan's answer is good. For completeness' sake; here's the regex:

var stripped = window.location.href.replace(/#.*$/,'');


window.location.hash = '';


url.substring(0,url.indexOf("#"))


If you want a regex based solution, you can use:

window.location.href.replace('#.*', '');
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜