浏览器解析xml与判断IE8浏览器

52 篇文章 0 订阅

解析过程中,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;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值