Recently, I encountered errors in some of my applications when I tried to run in IE 8. It took me couple of hours to figure out the cause and finally found out that its indexOf() method not supported in older IE browsers.

In case you experienced the same problem, here is a code snippet that would fix the issue.

Paste the code below into your JavaScript or jQuery right before the code where you use the indexOf() method.

if (!Array.prototype.indexOf) {
    Array.prototype.indexOf = function(elt /*, from*/) {
        var len = this.length >>> 0;
        var from = Number(arguments[1]) || 0;
        from = (from < 0)
            ? Math.ceil(from)
            : Math.floor(from);
        if (from < 0)
            from += len;

        for (; from < len; from++) {
            if (from in this &&
                this[from] === elt)
                return from;
        }
        return -1;
    };
}