Clicking Popup link, webpage goes back to top

Author: Zeeshan Arshad     1340     11/12/2010

Estimated reading time: 0 minutes, 24 seconds

Zeeshan Arshad - Lifestyle Blog

Problem: When you set HREF="#" and use onclick="" with javascript to open a page as popup, the your source page goes back to top whenever you click the link.

Reason: # Hash has special meaning and it uses to target an ID or NAME attribute. It is used without any reference so it causes this page to target itself and going no where.

Solution: Simply put return false; statement inside onclick="".

UPDATE: Simply use underscore with # hash sign e.g. href="#_"

« Return to Blog