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

function icPageInit() { $("icImgDiv" + icAlternate()).setOpacity(0); return true; } window.onload = icPageInit; 

This piece of Javascript code works fine in Firefox and Chrome, but with the "Expected Object" error 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 make it work?

+4
source share
4 answers

Figured it out.

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

I used version numbers added in javascript in the language attribute, which caused IE not to load prototype.js .

+13
source

Are you sure this: $ ("icImgDiv" + icAlternate ()) returns a link to an element? If so, have you tried using Microsoft Script Debugger / Visual Studio to debug when and where an exception occurs?

+2
source

Also check that the script tag type is "text / javascript". I had this error in IE8, and I fixed it by changing the type tag = script tag from "application / javascript" to "text / javascript".

+2
source

It's not a problem. IE8 has this error, I think ... Because it works fine with IE7 and another browser.

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

I used version numbers added in javascript in the language attribute, which is why IE did not load prototype.js.

-1
source

Source: https://habr.com/ru/post/1285730/


All Articles