dayana
dayana

Reputation: 79

Error 'undefined' is null or not an object in Internet Explorer

In my magento code 1 file is there. Name of file - header.phtml

I got error like 'undefined' is null or not an object.

And if i debug that page from IE itself than it will break code from "var hashIndex = frameId.indexOf('#');" from following code.

function getFrameId()
{
    var qs = parseQueryString(window.location.href);
    var frameId = qs["frameId"];

    var hashIndex = frameId.indexOf('#');

    if (hashIndex > -1)
    {
        frameId = frameId.substring(0, hashIndex);
    }

    return frameId;
}

Upvotes: 2

Views: 9592

Answers (3)

motsoup
motsoup

Reputation: 31

indexOf is not supported in IE. You will need to write your own indexOf function. For example:

//Implement indexOf. (IE/mshta doesn't have it)
if (!Array.prototype.indexOf) {
    Array.prototype.indexOf = function (obj, fromIndex) {
    if (fromIndex == null) {
        fromIndex = 0;
    } else if (fromIndex < 0) {
        fromIndex = Math.max(0, this.length + fromIndex);
    }
    for (var i = fromIndex, j = this.length; i < j; i++) {
        if (this[i] === obj)
            return i;
    }
    return -1;
  }; 

Upvotes: 3

Vlad Nicula
Vlad Nicula

Reputation: 3696

Try

 console.debug(qs); 

in firefox or chrome and inspect that object. Not only will you confirm that you have or haven't the frameId property in the object, but you'll also be able to inspect all the content of that object, and maybe find the information you're looking for in a different object key.

Upvotes: 0

Akash Yadav
Akash Yadav

Reputation: 2421

'undefined' is null or not an object means that the java script object that you invoked any method on , is either null or a value that doesn't support that particular method.

in this casevar frameId = qs["frameId"]; i think this returned null, could you see what the qs contains and if there are any value associated with frameid key

Upvotes: 1

Related Questions