Tuesday, June 23, 2009

Using link to trigger click event

I just spent almost a full day (not mentioning past frustrations) to find the cause of yet another strange IE6 behaviour. Here is what happened.

The web application I was debugging uses this:


<a href="javascript:void(0);" onclick="SomeJsFunction();">Call SomeJsFunction</a>

SomeJsFunction shows an iframe that continuously fetches images from a remote source. The link works fine for IE7, Firefox 2, and Firefox 3. Yet with IE6 somehow the iframe does not fetch any image at all. Why? That was the question that causes much debugging frustration.

Thanks to this particular post at dbug, I found out that the cause is that using "javascript" as a pseudo-protocol is apparently a bad thing. An alternative is to use "#". It ends my problem.

However, if you want to go further and be good, this topic at StackOverflow suggests many other, better alternatives.