Reputation: 684
I have a website and want to link it to a particular anchor on another page.
The original way of doing this would be to
<a href="/page#contact">Contact</a>
The new page would then be
http://website.com/page#contact
Is there a way to still link it to the anchor without having the url display as
http://website.com/page#contact
?
Thank You
Upvotes: 0
Views: 254
Reputation: 1074058
No. To do that, you'd have to be able to link to a page and force it to scroll without using a fragment ("#contact"), and there's no standard or common way to do that without code on the target page enabling it.
If you can write code for the target page, you could do this:
<script>
setTimeout(function() {
var hash = location.hash.replace(/^#$/, '');
if (hash) {
location.hash = "";
};
}, 0);
</script>
But again, you have to be able to put code on the target page.
Upvotes: 1