Clicking Popup link, webpage goes back to top

Author: Zeeshan Arshad     970     11/12/2010

Estimated reading time: 0 minutes, 24 seconds

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="#_"

Was this topic helpful?

Subscribe YouTube Channel

Zeeshan Arshad is a self-taught and multi-dimensional person with extraordinary track record of success with international clients and students.

Feel free to contact him for your project, training purpose or guidance.