Change this...
www.sample/sample.html#commentxxx?stuffhereIdontneed
into this...
www.sample/sample.html
I have it in a link so I think I need a regex?
document.write("<a href='"+ window.location.href.replace('?????', '') +
"?ThisIsAppendedLater'>sample</a>");
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?
document.write("<a href='"+ window.location.href.replace('?????', '') +
"?ThisIsAppendedLater'>sample</a>");
Share
Improve this question
edited Dec 7, 2010 at 8:47
gravityboy
asked Dec 7, 2010 at 8:40
gravityboygravityboy
8175 gold badges11 silver badges21 bronze badges
0
4 Answers
Reset to default 17Nathan'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('#.*', '');