I hate people that use javascript: in links!
Seriously. It’s just plain annoying, and it’s bad practice. Time and time again, I go and read an article, which has a few little pictures. Now, when we click a link, we expect it to open in the window (or tab) that we’re currently on. So instead of clicking an image, I’ll middle click it to open it in a new tab for viewing after I’m finished reading the page.
What should happen is that I have a few tabs showing the full image in them. What often does happen though is that instead, I have four or five tabs with blank pages and javascript:show_image_popup(…) or something in the address bar. It’s now very irritating to have to go back and find the article if I want to actually see the pictures.
So don’t ever do this:
<a href="javascript:show_image_popup('lolcat.jpg')"> ... </a>
The right way
<a href="lolcat.jpg" onclick="show_image_popup('lolcat.jpg')"> ... </a>
Notice that the link actually points to the picture now? This way, when I open the link in a new window, or a new tab, I actually see what I want to see – the picture. If I just normally click it though, the javascript runs and you can pop up your annoying image window. Now, I hear you asking “but won’t the browser navigate away from this page if the link is set to the picture?”. The answer is no, as long as you make sure your javascript function returns false.








