解析过程中,IE8及其以上,谷歌、火狐都需要解析xml,
解析属性:ajaxResponse[0].getAttribute("createFlag")
解析节点文本:ajaxResponse[0].childNodes[0].nodeValue
记住文本也是一个节点
以上操作支持任何浏览器
<%@ page contentType="text/xml;charset=utf-8"%><?xml version="1.0" encoding="utf-8"?> <ajax-response> <response type="object" id="" userServiceCode="${userServiceCode}" calculationPriceCode="${calculationPriceCode}" StrutsErrorIndex="${StrutsErrorIndex}" userName="${userName}" userCode="${userCode}" message="${message}" exception="${exception}" ResType="${ResType}" resStatus="${resStatus}" bussType ="${bussType}" invented ="${invented}" orgCode ="${orgCode}" msgSelectFlag ="${msgSelectFlag}" waitSeeSize = "${waitSeeSize}" opType ="${opType}" orgType="${orgType}" paramCode="${paramCode}" custCode="${custCode}" custEq="${custEq}" ifStatic="${ifStatic}" identification="${identification}" writeStr="${writeStr}" createFlag="${createFlag}" > ${tempMap} </response> </ajax-response>
var ajaxResponse = response.responseXML.getElementsByTagName("response"); if(ajaxResponse[0].getAttribute("createFlag") == 1){//保存页面 if(navigator.userAgent.indexOf("MSIE")>0){ if(navigator.userAgent.indexOf("MSIE 8.0")>0){//判断IE8浏览器 alert("IE8"); }else{//其他IE系列浏览器 alert("其他IE"); } }else{//其他浏览器 alert("其他浏览器"); } alert("value----------->"+ajaxResponse[0].childNodes[0].nodeValue);//得到文本节点的值 }
终极判断是否是IE浏览器:上面的方法对于IE11无法判断,下面的代码可以判断IE11
//判断是否是IE浏览器
function isIE() { //ie?
if (!!window.ActiveXObject || "ActiveXObject" in window)
return true;
else
return false;
}