Show # id in the URL when clicked

Hi, I have a custom code that will allow me to get the id assign after # for example

I can see it is working once I published it (Summary) but I have to export the code for my server.
However, the part #idhere is not showing in the browser.

How can I fix this?