Clicking Anchor link, it gets appended in URL. How to stop it? | Community
Skip to main content
sesmic
Level 4
December 6, 2022
Solved

Clicking Anchor link, it gets appended in URL. How to stop it?

  • December 6, 2022
  • 2 replies
  • 11589 views

Hi,
I'm using anchor links in page for some purpose within it. But when anchor link is clicked, it gets appended to URL in browser.

Suppose anchor link is #tab1, when it is clicked #tab1 gets added to URL (?wcmmode=disabled#tab1) which I don't want.

Is there any way I can stop this from happening?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by nitesh_kumar-1

Hi @sesmic,

 

As it is a browser feature you need to override the default behavior through the script. You might check this as well.

https://stackoverflow.com/questions/17012592/keep-url-unaffected-when-anchor-link-is-clicked 

 

Hope this helps.

 

Regards,

Nitesh

2 replies

nitesh_kumar-1
Adobe Employee
nitesh_kumar-1Adobe EmployeeAccepted solution
Adobe Employee
December 6, 2022

Hi @sesmic,

 

As it is a browser feature you need to override the default behavior through the script. You might check this as well.

https://stackoverflow.com/questions/17012592/keep-url-unaffected-when-anchor-link-is-clicked 

 

Hope this helps.

 

Regards,

Nitesh

Chandra_Hire
Level 4
December 6, 2022

Hi@sesmic 

anchor tag ids from the url can be hidden/removed by multiple ways as follows.

 

1. javascript - capture anchor tag click event and replace the unwanted tags

Check this video#16 - Remove anchor link id tag and # on urls when loading a page - YouTube

(Reference How to hide anchor tag from URL using jQuery (deanha.com)

2. Using CSS - (Reference - html - How to hide an anchor tag by href #id using css - Stack Overflow)

 

 

 

Hope this helps

 

Thanks,

Chandra