下面的代码运行在IE8和IE9出错:复制代码代码如下:
document.createelement(' ');
错误提示:例外:script5022:DOM的例外:(5)invalid_character_err

观念分析:
第一步:用IE9,Firefox,Opera兼容、Safari等浏览器;

复制代码代码如下:var IFRAME = document.createelement(漏洞);
iframe.setattribute(身份
iframe.setattribute(src
iframe.setattribute(风格


第二步:兼容IE6-8:因为IE6-8不能修改iframe的name属性
复制代码代码如下所示:
无功oframe =议document.createelement():document.createelement(漏洞);
oframe.name =iframname ;

全面的解决方案:
复制代码代码如下所示:
无功议=真的假的(文件。所有); / /这里简单地判断是否是IE浏览器,以判断:请参阅浏览器类型的检测
var ua = navigator.useragent.tolowercase()。比赛( / MSIE({或} + D) /){ 1 };
如果(UA = 9){
议= false;
}
无功oframe =议document.createelement():document.createelement(漏洞);oframe.name =iframname ;
/ / =========================

ajaxpost(之功能,showid,waitid,showidclass,submitbtn,召回){
无功waitid = typeof waitid = 'undefined'waitid空showid(| |:waitid!= =waitid);
无功showidclass =!showidclass:showidclass;
无功ajaxframeid = 'ajaxframe;
无功ajaxframe = $(ajaxframeid);
无功formtarget = $(之目标);

无功handleresult =函数(){()
var=;
无功evaled = false;

showloading(不关);
{试
S = $(ajaxframeid)。ContentWindow.document.XMLDocument.text;
} catch(e){
{试
S = $(ajaxframeid)。ContentWindow.document.documentElement.firstChild.wholeText;
} catch(e){
{试
S = $(ajaxframeid)。ContentWindow.document.documentElement.firstChild.nodeValue;
} catch(e){
s内部错误,没有显示此内容;
}
}
}

如果(S!= ' ' s.indexof('ajaxerror)!= 1){
Evalscript(S);
evaled =真;
}
如果(showidclass){
$(showid classname = showidclass);
如果(submitbtn){
submitbtn.disabled = false;
}
}
如果(!Evaled (typeof ajaxerror ='undefined'ajaxerror ||!)) {
ajaxinnerhtml($(showid),S);
}
当= null;
如果($(之))$(之)。目标= formtarget;
如果(typeof回忆= = 'function){
召回();
{人}
Eval (recall);
}
如果(!evaled)evalscript(S);
ajaxframe.loading = 0;
$('append_parent)。RemoveChild(ajaxframe);
};
如果(!ajaxframe){
{试
ajaxframe = document.createelement(' ');
} catch(e){
ajaxframe = document.createelement('iframe);
ajaxframe.name = ajaxframeid;
ajaxframe.id = ajaxframeid;
}
ajaxframe.style.display =不关;
ajaxframe.loading = 1;
$('append_parent)。AppendChild(ajaxframe);
如果(ajaxframe。加载){ }
返回false;
}

_attachevent(ajaxframe,负荷,handleresult);

showloading();
$(之)。目标= ajaxframeid;
$(之)。行动= 'inajax = 1;
$(之)提交();
返回false;
}