IE8不支援indexOf的解決辦法

2022-05-24 13:03:15 字數 1071 閱讀 2838

在ie8版本以下(含ie8)ie瀏覽都不支援陣列的indexof()方法,在使用indexof方法前,執行一下下面的js就可以解決。 原理就是如果發現陣列沒有indexof方法,會新增上這個方法。

放在指令碼的上面即可

// production steps of ecma-262, edition 5, 15.4.4.14

// reference:

if (!array.prototype.indexof)

var o = object(this);

// 2. let lenvalue be the result of calling the get

// internal method of o with the argument "length".

// 3. let len be touint32(lenvalue).

var len = o.length >>> 0;

// 4. if len is 0, return -1.

if (len === 0)

// 5. if argument fromindex was passed let n be

// tointeger(fromindex); else let n be 0.

var n = fromindex | 0;

// 6. if n >= len, return -1.

if (n >= len)

// 7. if n >= 0, then let k be n.

// 8. else, n<0, let k be len - abs(n).

// if k is less than 0, then let k be 0.

k = math.max(n >= 0 ? n : len - math.abs(n), 0);

// 9. repeat, while k < len

while (k < len)

k++;

}return -1;

};}

IE8不支援jQuery問題

最近做wordpress主題,遇到乙個很奇怪的問題,網頁在chrome等瀏覽器都顯示正常,但是到了ie8裡面就無法工作。提示 載入完畢,但網頁中有錯誤 嘗試修復ie瀏覽器,但是毫無效果。後來經過反覆排查,發現問題在於ie8不能執行jquery。網上找了很久也沒找到相關的文章。而且之前用過一些jque...

ewebeditor不支援IE7 8 9的解決辦法

1 首先找到ewebeditor編輯器所在的目錄,然後搜尋到editor.js檔案,由於ewebeditor有很多個版本,所以editor.js檔案所在的目錄也有所不同,有的可能在include目錄下,有的可能在js目錄下。2 用記事本開啟editor.js檔案,找到如下 if element.yu...

解QC9不支援IE 7,IE 8訪問

用ie8訪問qc出現下面的錯誤 microsoft internet explorer 4.0 compatible msie 8.0 windows nt 6.1 wow64 trident 4.0 slcc2 net clr 2.0.50727 net clr 3.5.30729 net clr...