# Why is a # sign added to the end of URLS?

Note: I'm asking this from the perspective of the site developers (trying to help someone there). not as a user. Please don't forward this to superuser.com. It's a server admin question.

Have a look here

http://www.wanimo.com/fr/chiens/coussin-matelas-tapis-pour-chien-sc28/tapis-plat-urban-chic-sf7263/

you'll see that the page gets redirected to the same page with # at the end. Worse, when you click back you get garbage url.

I'm trying to debug what is causing the redirect. Any advice on how to find it ?

-

## migrated from serverfault.comOct 25 '10 at 19:27

This question came from our site for system and network administrators.

This is not a question written in the perspective of a server admin. This looks like a user question. It's obvious there is an ad taking over the main page, and closing it causes the ad to redirect you to a completely legal url of site.com/# –  l0c0b0x Oct 25 '10 at 17:50
Please don't post shortened URLs. There's no reason for that here. By the way, I don't get a #. Also, this question may be better suited for webmasters.stackexchange.com. –  Dennis Williamson Oct 25 '10 at 18:56

I never got the floating Ad, but I assume the ad is triggered on a cookie (didn't check to see if it was longterm or session yet). The pound sign (#) is there for adding hash tags to the page. I use this a ton to pass along javascript variables to functions on the page. It's similar to passing variables the normal way ../somepage.html?x=1&y=2 except it's a little more friendly to javascript.

Also these work the old fashion way as anchor links. If I wanted you to jump to a specific section of the page after it loads I could push the anchor tag in the URL forcing your viewport to jump down the page to the specific point.

Personally, I'm guessing a link on that ad has a link that is incorrectly configured to point to href="#" and the onclick event is causing the function. This is a really common mistake when using javascript with a function and not making it return false to avoid applying the hash tag.

-

I don't see the # until after the JavaScript floating ad appears and I then dismiss it. I would assume the JavaScript that makes that happen is doing it. When I went back a second time there was no ad and no redirect.

-

the cause of the problem is the ad. It has a link to close itself (Fermer). In the onclick event of the link there is a function call: fermeture(). The href is "#". But there is no return false in the onclick event, which means, the page http://www.wanimo.com/fr/chiens/coussin-matelas-tapis-pour-chien-sc28/tapis-plat-urban-chic-sf7263/# is loaded.

To solve this problem, the ad window should look like this: <a href="#" onclick="fermeture(); return false">Fermer</a>

In an onclick event of a link "return false" means that the page will not redirected to the url in the href attribute, but it will stay on the current page, as if nothing had happened.

-