Junal on the run

Solving Javascript onclick() issue in IE6

Posted by: junal on: April 27, 2008

We always face css issues that work in FF/IE7 but not in IE6! That’s a common scenario. But Javascript? Well that’s too. Yesterday I faced this problem while I was working on an onclick event of JS.

To avoid the link execution I used href=”javascript:fx()” which worked fine in FF and IE7 but when I went to test with IE6 it all went wrong. Weird problem. Had no idea why it didn’t work and after goggling for sometimes I found the solution which was like instead of href=”javascript:fx()” I had to use href=”#” and my onclick was finished with “return false” to prevent the link from being executed. Nice trick! Google is the best!

1 Response to "Solving Javascript onclick() issue in IE6"

This is a known IE6 bug (that thankfully was fixed in IE7)

You’ll want to alter your fix to what is posted here
http://webbugtrack.blogspot.com/2007/09/bug-223-magical-http-get-requests-in.html

because you’re going to have issues with your posting. By using “#” your user will be scrolled to the top of the page (unwanted)… set a dummy hash value instead that will not cause scrolling “#ie6hack”.

There’s a new anchor bug in IE8 Beta 1 too! which will hopefully get fixed before ship time.

Leave a Reply

View Junal Rahman's profile on LinkedIn
Subscribe to me on FriendFeed

Follow Me on Twitter

Archives

My photos

DSCF1137

DSCF1141

DSCF1134

DSCF1062

DSCF1119

DSCF1129

DSCF1116

DSCF1091

More Photos

Blog Stats

  • 131,322 hits