錯誤訊息
無法取得未定義或 Null 參考的屬性 'open'發生問題的地方是 mm_menu.js 第 297 行。
根據這篇文章 IE10: msxml.load(document.all(“UserInfo”) is throwing an error
這是因為 document.all 是很舊的寫法。它是非標準的,而且存在這麼久只是為了跟 IE 5 相容。現在應該使用
document.getElementById() 。這篇文章 Hover menu’s utilizing mm_menu.js fail in IE10 and greater ,有提供幾個具體的替代修正方式。
方法一:
//原本的 mm_menu.js
function FIND(item) {
if( window.mmIsOpera ) return(document.getElementById(item));
if (document.all) return(document.all[item]);
if (document.getElementById) return(document.getElementById(item));
return(false);
}
//建議方式:調換順序
function FIND(item) {
if( window.mmIsOpera ) return(document.getElementById(item));
if (document.getElementById) return(document.getElementById(item));
if (document.all) return(document.all[item]);
return(false);
}
//我是覺得,既然 document.all 已被棄用,何不直接刪除。
function FIND(item) {
if( window.mmIsOpera ) return(document.getElementById(item));
if (document.getElementById) return(document.getElementById(item));
return(false);
}
方法二
//原本的 mm_menu.js
if ((!document.all) && (container.hasChildNodes) && !window.mmIsOpera) {
container.innerHTML=content;
} else {
container.document.open("text/html");
container.document.writeln(content);
container.document.close();
}
//改成
if (((!document.all) && (container.hasChildNodes) && !window.mmIsOpera) || (navigator.appVersion.indexOf(“MSIE 10″)>0)) {
container.innerHTML=content;
} else {
container.document.open("text/html");
container.document.writeln(content);
container.document.close();
}
這樣是強制 IE 10 使用第一段 if 的內容。方法三
//同一段,但是直接把 document.all 拿掉
if ((!document.all) && (container.hasChildNodes) && !window.mmIsOpera) {
//改成
if (container.hasChildNodes && !window.mmIsOpera) {
沒有留言:
張貼留言