Bala
Bala

Reputation: 3638

How to avoid the id getting displayed in the address bar when a user click that link?

I have an anchor tag inside a <li> tag like this

<li><a href="#fragment-1">Primary Details</a></li>

But the problem is that I want the link to show the div with id fragment-1. but after the link is clicked, the div id is being displayed in the url like below

http://localhost:90/index.php#fragment-1 

How can i stop the div id being displayed with the url ??

Upvotes: 1

Views: 1166

Answers (2)

Manigandan Arjunan
Manigandan Arjunan

Reputation: 2265

can you try with this

 <script language="javascript" type="text/javascript">
function redirect(URL)
{
   document.location=URL;
   return false;
}
</script>
    <a href="#fragment-1" onclick="return redirect('http://localhost:90/index.php');">Click here</a>

Upvotes: 2

Ayman Safadi
Ayman Safadi

Reputation: 11552

You can't, naturally anyways. You can try some clever JavaScript to mimic this behavior and leave the URL unscathed.

Personally, I like the #hashtags in the URLs. Sometime I want to share a link and point the reader to a specific part of the page.

Upvotes: 1

Related Questions