سؤال

I'm working on an ASP.NET application that has to be compatible with IE8. In all other browsers it works perfectly, but in IE8 it gives me the error

Object doesn't support this property or method

and crashes. I have done some searches around the internet and found questions like this one with solutions (like this one or this one), but none of those solutions change my situation. The error occurs at the initialize callback method of a google map initialization (which shouldn't make a difference, since the error seems to occur on a variable definition line), at the following code:

function initialize(sender, isFrontPageInitialLoadParam) {
    if (isFrontPageInitialLoadParam !== false) {
        isFrontPageInitialLoad = true;
        mapCompletelyLoaded = false;
    } else {
        isFrontPageInitialLoad = false;
    }

(The function of course continues, but the error occurs in this code.)

The production (minified) version of this code is the following:

function initialize(n, t) {
    var i, r;
    t !== !1 ? (isFrontPageInitialLoad = !0, mapCompletelyLoaded = !1) : isFrontPageInitialLoad = !1,

And the error occurs at the t !== !1, which would be the equivalent of if (isFrontPageInitialLoadParam !== false).

From the other solutions to this error, it seems that the error usually occurs because of implicitly declared global variables, but I don't see that this is an issue in my case (isFrontPageInitialLoad and mapCompletelyLoaded are variables declared in the global scope).

Am I missing something obvious or is IE8 just not playing nice as usual?

هل كانت مفيدة؟

المحلول

So I figured out the issue with a little help from a friend.

It didn't seem right that this variable check would be the issue, so I started putting alerts in my code at different places in the code to see how far it got, and alas: the error happened on an entirely different line.

It appeared I had a left over

console.dir("<snip>")

call in the JavaScript, and it does not look like IE8 supports the console.dir() call, but the console.log() call is still supported if the developer tool is open (thanks to @Reinder Wit). I removed this line, and it worked again.

If you encounter an error like this, throw in some alerts at various lines in your code and see how far the code gets before crashing. It seems like the JavaScript error logging console in IE8 does not know the correct parts of your code where errors occur.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top