0

Looking up this matter it seems to me that nobody pointed out that using "#" for "href" in a link will scroll the page to the top where javascript:function() will not. I have a page similar to Google images; this page displays hundreds of thumbnails which when clicked pop up a larger size of the thumbnail. To have the page scrolling at every click is very annoying!

alberto
  • 115
  • 4
  • 19
  • What's exactly your question ? – Denys Séguret May 10 '14 at 07:50
  • If you set href='#', and also create an onclick event listener for the link, and have that listener return false, then the link won't go to the top of the page. Most of the time when you set href='#', you are setting an onclick event anyway. – Cully May 10 '14 at 07:51

1 Answers1

0

It is well known to developers that if you just use href='#' then the page scrolls to the top.

I always use href='javascript:void(0)' instead

Check this discussion: Which "href" value should I use for JavaScript links, "#" or "javascript:void(0)"?

Community
  • 1
  • 1
Ted
  • 3,985
  • 1
  • 20
  • 33