JavaScript trivia tidbit for all you FF2 developers

Did you know, that in Firefox 2, creating a link like:

<a href="javascript:">click me!</a>

will actually open up the Firefox error console?


You’d think it’d do nothing, since the href is just “javascript:”, but that’s not the case. To do nothing you need a bit more:

<a href="javascript:;">click me!</a>
<a href="javascript:void(0)">click me!</a>

Notice the semicolon in that first line. If you leave out that semicolon (or a void(0)), then your users will enjoy looking at the error console instead of your site – yikes!

Other fixes:

You can stop this from happening if you go to Web Developer’s Options
drop-down menu and then choose Options.  Then choose Miscellaneous tab
and untick all the boxes for Error Console.

change your a href with onclick
from something like:

<a onclick="OpenPopUp();" href="javascript:">...</a>


<a onclick="OpenPopUp();return false;" href="javascript:">...</a>

… in other words, just add ‘return false;’

Leave a Reply

Your email address will not be published. Required fields are marked *