Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap

Q1074 Weird things happen using onClick with a link

You are here: irt.org | FAQ | JavaScript | Bugs | Q1074 [ previous next ]

Symptom: Clicking on a link (<A HREF="..." onClick="myFunction()"> does not do anything or goes somewhere.

Affects: Many browsers - especially Internet Explorer

Workaround: <A HREF="javascript:myVoid()" onClick="somejavascript" where myVoid looks like this:

function myVoid() { ; } // do nothing

<A HREF="somewhere.html" - does not trigger onClick in Internet Explorer and if you use
<A HREF="javascript:somejavascript..." - any form submits or location changes must be done in that javascript (remember to return false in the onClick for Netscape).

Although severely cool, <A HREF="javascript:A_Function_That_Returns_Html()" - can trigger the Netscape 4.04 bug.

Feedback on 'Q1074 Weird things happen using onClick with a link'

©2018 Martin Webb