I recent ran into an interesting IE bug involving the following bit of html code:
<a href="javascript: void(0);" onclick="dosomething();">click me</a>
I honestly did not write this one but I will leave names out of this to protect the innocent =)
The void(0) JavaScript code is usually used to prevent loading or reloading of the page when the user clicks a the link.
What we were trying to do here was have the dosomething JavaScript function execute when a user clicks on the link. This works fine in FireFox, Chrome, Safari but not IE. When a user clicks on the link in IE, nothing happens: i.e. (no pun intended) the JavaScript does not execute.
It took us a good amount of time to realize what the issue was with IE. It turns out that the void(0) function was preventing the onclick event to fire.
Although it may not be pretty, this is what we ended up doing and it appears to be cross-browser friendly:
<a href="<?=$_SERVER['PHP_SELF'];>#" onclick="dosomething();">click me</a>
Anyway, I hope this helps someone out there in the universe.
Share with a friend:Customize message