Anchor tag with onclick / JavaScript attribute. Stop the update page in IE

I have an HTML / JavaScript project containing a few dozen anchor tags; each anchor tag is the same JavaScript function, but with a different parameter.

Everything looks fine in Firefox and Chrome, but in Internet Explorer (IE) page appears, restarts (flashing) every time I push the anchor tag (as shown below). How can I get IE to stop the reboot / flickering? I'd rather not rewrite the entire script. I tried onclcick = 'javascript ... and href =' javascript ... but both have the same problem (although onclick seems a little better).

<a onclick='javascript:foo(22)'></a> 
+4
source share
2 answers

Try <a onclick='foo(22); return false;'></a> <a onclick='foo(22); return false;'></a>

In addition, javascript: it does not make sense in the event attributes, since it simply defines a label.

+10
source

Easier to use jQuery:

 <a href="#" class="action" rel="22"></a> <script> $('.action').click(function(){ yourfunction($(this).attr('rel'); return false; }); </script> click (function () { <a href="#" class="action" rel="22"></a> <script> $('.action').click(function(){ yourfunction($(this).attr('rel'); return false; }); </script> 
+1
source

All Articles