'Object Expected' Javascript error in IE8 when using prototype.js

user47322 picture user47322 · Jun 4, 2009 · Viewed 43.5k times · Source
function icPageInit()
{
    $("icImgDiv" + icAlternate()).setOpacity(0);
    return true;
}
window.onload = icPageInit;

This piece of Javascript code works fine in Firefox and Chrome, but fails with the error 'Object Expected' in Internet Explorer 8. IE8 says the error occurs on line 3 of the above code.

Does anyone know why this is happening, and/or how to get it working?

Answer

user47322 picture user47322 · Jun 27, 2009

Figured it out.

Turns out Internet Explorer chokes if you use anything other than "javascript" in the language attribute of the script tag.

I was using version numbers appended onto javascript in the language attribute, which was causing IE not to load prototype.js.