Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

document.write("<a href='"+ window.location.href.replace('?????', '') +  
"?ThisIsAppendedLater'>sample</a>");  
like image 860
gravityboy Avatar asked Nov 29 '22 10:11

gravityboy


1 Answers

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

var stripped = window.location.href.replace(/#.*$/,'');
like image 106
Linus Kleen Avatar answered Dec 01 '22 01:12

Linus Kleen