Cody Bennett Cody Bennett - 4 years ago 137
HTML Question

Hide # From Urls Javascript

after working on an interactive site that automatically navigates using ids in the url, I was wondering how to hide that while it will still navigate normally. After some research on here, I found the following script which doesn't work for me.

if ($.browser.msie && parseInt($.browser.version, 10) === 9 && window.location.href.indexOf("#"))
document.location.href = String( document.location.href ).replace( /#/, "" );

Answer Source

Try this instead:

var loc = document.location.href;
if (loc.indexOf("#") !== -1) {
    document.location.href = loc.replace(/#.+$/, "");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download