Saahir Foux
Saahir Foux

Reputation: 674

Onclick Event Issue in IE 7

I'm thoroughly confused now. Exclusively in IE7 my onclick function fails to execute. However, when I run it in IE's console, it works just fine.

I've tried the following combinations:

onclick="loadStatsRSH('h',2)" href="javascript:void(0)"
onclick="loadStatsRSH('h',2);return false;" href="javascript:void(0)"
onclick="loadStatsRSH('h',2);return false;" href="#"
onclick="loadStatsRSH('h',2)" href="#"
onclick="javascript:loadStatsRSH('h',2);return false;" href="#"
onclick="javascript:loadStatsRSH('h',2);" href="javascript:void(0)"

There are other which I've tried, but now I feel its getting silly. Can anyone give me a hint why IE7 would complain about my onclick?

Upvotes: 2

Views: 2099

Answers (1)

jfriend00
jfriend00

Reputation: 707258

It works fine here: http://jsfiddle.net/jfriend00/KHY52/ in any version of IE I try it in with this HTML:

<a onclick="loadStatsRSH('h',2);return false;" href="#">Click here</a>

One possibility is that your loadStatsRSH function isn't in the global scope and thus the browser can't find it (though it would be unlikely that that would be a problem in only IE).

If you want further help, the problem is probably caused by parts of your web page that you haven't disclosed as there is nothing wrong with the choices you have above. I'd suggest describing/showing more of your HTML and more of your script.

Upvotes: 2

Related Questions