I’ve got a web page that works just fine in Firefox but not in IE 8. It includes HTML that looks like this:
<a href="#" onclick="myFunc(0);">Call myFunc</a>
and in my JavaScript, it includes something like this:
function myFunc(num) { alert("got here"); }
In Firefox, clicking on the link displays the alert. In Internet Explorer, it produces an "Object expected" error.
I did a little poking around and I learned that myFunc is not defined in IE.
<a href="#" onclick="alert("Type is:" + typeof(myFunc));">Call myFunc</a>
produces an alert which says, "Type is:undefined".
I defined the function in a systemConfig Tiddler in my TiddlyWiki, so I thought maybe it was something funky about TiddlyWiki. It turns out that IE has a quirk, in that global functions aren’t visibly globally by default. Or, maybe it is that references to apparently global functions are qualified with "window."
At any rate, changing my JavaScript to:
function myFunc(num) { alert("got here"); } window.myFunc = myFunc;
resolved the problem.