0

I am trying to make some links that redirect the user to a certain part (div) of the page. I am using anchors for that reason but I get the www.f f f.com/#anchor link on my browser's tab. All I want is to see www.f f f.com so that the hashtag is not shown on the url.

Here is the code of the link that redirects me to the specific part of the page:

<a href="#anchor" id="aboutme">SPECIFIC_PART_OF_PAGE</a>

and here is the code of the div where I am being directed after clicking the link:

<div id="anchor" class="title" ">HERE_WE_ARE</div>

I am trying this to make it work in a jquery:

$('#aboutme').click(function(e)
{
e.preventDefault();
$('#aboutme').hide();
$('#anchor').show();
$(window).scrollTop($('#anchor').offset().top);
});

It does work, but I see that the link "HERE_WE_ARE" has now disappeared. It is not visible. What should I do to hide it from the url shown on my browser tab and still have it in the menu?

Datacrawler
  • 2,780
  • 8
  • 46
  • 100

1 Answers1

0

That is the intended functionality for anchors. If you must remove them this answer might help. But I would suggest leaving them. I personally use them all the time especially on SO. It helps tell your users where they are.

Community
  • 1
  • 1
sareed
  • 665
  • 9
  • 19
  • I want to learn how to hide them. I am not sure if I am going to use them. – Datacrawler Jan 27 '15 at 16:59
  • lol after what I said I did not even use it in the link :/ the updated link should show you how. – sareed Jan 27 '15 at 17:01
  • sareed I found it :P I realized that there was something after scrolling. Is there a way to change the current jquery and use something like that? if (url.indexOf('www. f f f.com') >= 0) { $('#anchor').hide(); } – Datacrawler Jan 27 '15 at 17:23
  • With the $('.class') jQuery selector you are getting the element, so when you hide it the element disappears. To remove strings from the URL you will have to use a different approach. – sareed Jan 27 '15 at 17:26
  • sareed What is the best way then? htaccess? I still can't find how to compose a htacess file for that. I wish I could find a ready file to understand how it works. – Datacrawler Jan 27 '15 at 19:57