Discuz7.2 IE9兼容性寫法 杜工完全修補(bǔ)方案
發(fā)布時間:2013-07-22 23:04:34 作者:杜工
我要評論
因為Discuz7.2在IE9瀏覽器中有一系列的問題,所有要在以后的開發(fā)中考慮到ie9瀏覽器的一些問題了,這里簡單介紹下,需要的朋友可以參考下
現(xiàn)象:
1. IE9快速發(fā)帖不跳轉(zhuǎn)
2. IE9管理員處理帖子失敗
3. IE9登錄不跳轉(zhuǎn),需要手動刷新
原因:
1. AJAXPOST函數(shù)判斷out了
2. 動態(tài)創(chuàng)建iframe時各瀏覽器處理方式不同
解決方法:
1. 修改templates/header.htm
把
<meta http-equiv=”x-ua-compatible” content=”ie=7″ />
替換為
<!–[if lte IE 8]>
<meta http-equiv=”x-ua-compatible” content=”ie=7″ />
<![endif]–>
<!–[if IE 9]>
<meta http-equiv=”x-ua-compatible” content=”ie=9″ />
<![endif]–>
2.修改include/js/common.js
把a(bǔ)jaxpost函數(shù)替換為:
function ajaxpost(formid, showid, waitid, showidclass, submitbtn, recall) {
var waitid = typeof waitid == 'undefined' || waitid === null ? showid : (waitid !== '' ? waitid : '');
var showidclass = !showidclass ? '' : showidclass;
var ajaxframeid = 'ajaxframe';
var ajaxframe = $(ajaxframeid);
var formtarget = $(formid).target;
var handleResult = function() {
var s = '';
var evaled = false;
showloading('none');
try {
s = $(ajaxframeid).contentWindow.document.XMLDocument.text;
} catch(e) {
try {
s = $(ajaxframeid).contentWindow.document.documentElement.firstChild.wholeText;
} catch(e) {
try {
s = $(ajaxframeid).contentWindow.document.documentElement.firstChild.nodeValue;
} catch(e) {
s = '內(nèi)部錯誤,無法顯示此內(nèi)容';
}
}
}
if(s != '' && s.indexOf('ajaxerror') != -1) {
evalscript(s);
evaled = true;
}
if(showidclass) {
$(showid).className = showidclass;
if(submitbtn) {
submitbtn.disabled = false;
}
}
if(!evaled && (typeof ajaxerror == 'undefined' || !ajaxerror)) {
ajaxinnerhtml($(showid), s);
}
ajaxerror = null;
if($(formid)) $(formid).target = formtarget;
if(typeof recall == 'function') {
recall();
} else {
eval(recall);
}
if(!evaled) evalscript(s);
ajaxframe.loading = 0;
$('append_parent').removeChild(ajaxframe);
};
if(!ajaxframe) {
try{
ajaxframe = document.createElement('<iframe name="' + ajaxframeid + '" id="' + ajaxframeid + '"></iframe>');
}catch(e){
ajaxframe = document.createElement('iframe');
ajaxframe.name = ajaxframeid;
ajaxframe.id = ajaxframeid;
}
ajaxframe.style.display = 'none';
ajaxframe.loading = 1;
$('append_parent').appendChild(ajaxframe);
} else if(ajaxframe.loading) {
return false;
}
_attachEvent(ajaxframe, 'load', handleResult);
showloading();
$(formid).target = ajaxframeid;
$(formid).action += '&inajax=1';
$(formid).submit();
return false;
}
后臺刷新緩存,搞定。
1. IE9快速發(fā)帖不跳轉(zhuǎn)
2. IE9管理員處理帖子失敗
3. IE9登錄不跳轉(zhuǎn),需要手動刷新
原因:
1. AJAXPOST函數(shù)判斷out了
2. 動態(tài)創(chuàng)建iframe時各瀏覽器處理方式不同
解決方法:
1. 修改templates/header.htm
把
<meta http-equiv=”x-ua-compatible” content=”ie=7″ />
替換為
復(fù)制代碼
代碼如下:<!–[if lte IE 8]>
<meta http-equiv=”x-ua-compatible” content=”ie=7″ />
<![endif]–>
<!–[if IE 9]>
<meta http-equiv=”x-ua-compatible” content=”ie=9″ />
<![endif]–>
2.修改include/js/common.js
把a(bǔ)jaxpost函數(shù)替換為:
復(fù)制代碼
代碼如下:function ajaxpost(formid, showid, waitid, showidclass, submitbtn, recall) {
var waitid = typeof waitid == 'undefined' || waitid === null ? showid : (waitid !== '' ? waitid : '');
var showidclass = !showidclass ? '' : showidclass;
var ajaxframeid = 'ajaxframe';
var ajaxframe = $(ajaxframeid);
var formtarget = $(formid).target;
var handleResult = function() {
var s = '';
var evaled = false;
showloading('none');
try {
s = $(ajaxframeid).contentWindow.document.XMLDocument.text;
} catch(e) {
try {
s = $(ajaxframeid).contentWindow.document.documentElement.firstChild.wholeText;
} catch(e) {
try {
s = $(ajaxframeid).contentWindow.document.documentElement.firstChild.nodeValue;
} catch(e) {
s = '內(nèi)部錯誤,無法顯示此內(nèi)容';
}
}
}
if(s != '' && s.indexOf('ajaxerror') != -1) {
evalscript(s);
evaled = true;
}
if(showidclass) {
$(showid).className = showidclass;
if(submitbtn) {
submitbtn.disabled = false;
}
}
if(!evaled && (typeof ajaxerror == 'undefined' || !ajaxerror)) {
ajaxinnerhtml($(showid), s);
}
ajaxerror = null;
if($(formid)) $(formid).target = formtarget;
if(typeof recall == 'function') {
recall();
} else {
eval(recall);
}
if(!evaled) evalscript(s);
ajaxframe.loading = 0;
$('append_parent').removeChild(ajaxframe);
};
if(!ajaxframe) {
try{
ajaxframe = document.createElement('<iframe name="' + ajaxframeid + '" id="' + ajaxframeid + '"></iframe>');
}catch(e){
ajaxframe = document.createElement('iframe');
ajaxframe.name = ajaxframeid;
ajaxframe.id = ajaxframeid;
}
ajaxframe.style.display = 'none';
ajaxframe.loading = 1;
$('append_parent').appendChild(ajaxframe);
} else if(ajaxframe.loading) {
return false;
}
_attachEvent(ajaxframe, 'load', handleResult);
showloading();
$(formid).target = ajaxframeid;
$(formid).action += '&inajax=1';
$(formid).submit();
return false;
}
后臺刷新緩存,搞定。
相關(guān)文章
這篇文章主要介紹了淺談原生頁面兼容IE9問題的解決方案,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起2020-12-16新版chrome瀏覽器設(shè)置允許跨域的實現(xiàn)
這篇文章主要介紹了新版chrome瀏覽器設(shè)置允許跨域的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起2020-11-30css hack之\9和\0就可能對hack IE11\IE9\IE8無效
每次設(shè)計一張網(wǎng)頁或一個表單,都被各種瀏覽器的兼容問題傷透腦筋,尤其是IE家族。在做兼容性設(shè)計時,我們往往會使用各種瀏覽器能識別的獨(dú)特語法進(jìn)行hack,從而達(dá)到各種瀏覽2020-03-20css區(qū)分ie8/ie9/ie10/ie11 chrome firefox的代碼
這篇文章主要介紹了css區(qū)分ie8/ie9/ie10/ie11 chrome firefox的代碼,需要的朋友可以參考下2020-03-20
這篇文章主要介紹了解決CSS瀏覽器兼容性問題的4種方案,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)2020-02-28
這篇文章主要介紹了常見的瀏覽器兼容性問題(小結(jié)),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)2020-02-20
這篇文章主要介紹了border-radius IE8兼容處理的方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)2020-02-12- 這篇文章主要介紹了淺談遇到的幾個瀏覽器兼容性問題,詳細(xì)的介紹了幾種我遇到的問題和解決方式,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-09-26
這篇文章主要介紹了base64圖片在各種瀏覽器的兼容性處理的相關(guān)資料,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-09-14
對常見的css屬性進(jìn)行瀏覽器兼容性總結(jié)(推薦)
這篇文章主要介紹了對常見的css屬性進(jìn)行瀏覽器兼容性總結(jié)(推薦)的相關(guān)資料,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-07-20






