Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1074 Weird things happen using onClick with a link

irt.org | Knowledge Base | JavaScript | Bugs | Q1074 [ previous next ]

Q1074 Weird things happen using onClick with a link

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:

<SCRIPT>
function myVoid() { ; } // do nothing
</SCRIPT>

because
<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'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.