Discuz7.2 IE9兼容性寫(xiě)法 杜工完全修補(bǔ)方案
發(fā)布時(shí)間:2013-07-22 23:04:34 作者:杜工
我要評(píng)論

因?yàn)镈iscuz7.2在IE9瀏覽器中有一系列的問(wèn)題,所有要在以后的開(kāi)發(fā)中考慮到ie9瀏覽器的一些問(wèn)題了,這里簡(jiǎn)單介紹下,需要的朋友可以參考下
現(xiàn)象:
1. IE9快速發(fā)帖不跳轉(zhuǎn)
2. IE9管理員處理帖子失敗
3. IE9登錄不跳轉(zhuǎn),需要手動(dòng)刷新
原因:
1. AJAXPOST函數(shù)判斷out了
2. 動(dòng)態(tài)創(chuàng)建iframe時(shí)各瀏覽器處理方式不同
解決方法:
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)部錯(cuò)誤,無(wú)法顯示此內(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;
}
后臺(tái)刷新緩存,搞定。
1. IE9快速發(fā)帖不跳轉(zhuǎn)
2. IE9管理員處理帖子失敗
3. IE9登錄不跳轉(zhuǎn),需要手動(dòng)刷新
原因:
1. AJAXPOST函數(shù)判斷out了
2. 動(dòng)態(tài)創(chuàng)建iframe時(shí)各瀏覽器處理方式不同
解決方法:
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)部錯(cuò)誤,無(wú)法顯示此內(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;
}
后臺(tái)刷新緩存,搞定。
相關(guān)文章
- 這篇文章主要介紹了淺談原生頁(yè)面兼容IE9問(wèn)題的解決方案,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起2020-12-16
新版chrome瀏覽器設(shè)置允許跨域的實(shí)現(xiàn)
這篇文章主要介紹了新版chrome瀏覽器設(shè)置允許跨域的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起2020-11-30css hack之\9和\0就可能對(duì)hack IE11\IE9\IE8無(wú)效
每次設(shè)計(jì)一張網(wǎng)頁(yè)或一個(gè)表單,都被各種瀏覽器的兼容問(wèn)題傷透腦筋,尤其是IE家族。在做兼容性設(shè)計(jì)時(shí),我們往往會(huì)使用各種瀏覽器能識(shí)別的獨(dú)特語(yǔ)法進(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瀏覽器兼容性問(wèn)題的4種方案,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)2020-02-28
常見(jiàn)的瀏覽器兼容性問(wèn)題(小結(jié))
這篇文章主要介紹了常見(jiàn)的瀏覽器兼容性問(wèn)題(小結(jié)),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)2020-02-20- 這篇文章主要介紹了border-radius IE8兼容處理的方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)2020-02-12
淺談?dòng)龅降膸讉€(gè)瀏覽器兼容性問(wèn)題
這篇文章主要介紹了淺談?dòng)龅降膸讉€(gè)瀏覽器兼容性問(wèn)題,詳細(xì)的介紹了幾種我遇到的問(wèn)題和解決方式,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-09-26- 這篇文章主要介紹了base64圖片在各種瀏覽器的兼容性處理的相關(guān)資料,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-09-14
對(duì)常見(jiàn)的css屬性進(jìn)行瀏覽器兼容性總結(jié)(推薦)
這篇文章主要介紹了對(duì)常見(jiàn)的css屬性進(jìn)行瀏覽器兼容性總結(jié)(推薦)的相關(guān)資料,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-07-20