Solving Javascript onclick() issue in IE6
Posted on: April 27, 2008
- In: IE | JavaScript
- 1 Comment
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!










April 30, 2008 at 9:06 am
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.