ajax 火狐不兼容
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Ip</title>
</head>
<body>
<table><tr>
<td><span id="datetime"></span></td>
<td> </td>
<td><div id="dataDiv"></div> </td></tr></table>
<script type="text/javascript" language="javascript" >
function gb2utf8(data){
var glbEncode = [];
gb2utf8_data = data;
execScript("gb2utf8_data = MidB(gb2utf8_data, 1)", "VBScript");
var t=escape(gb2utf8_data).replace(/%u/g,"").replace(/(.{2})(.{2})/g,"%$2%$1").replace(/%([A-Z].)%(.{2})/g,"@$1$2");
t=t.split("@");
var i=0,j=t.length,k;
while(++i<j) {
k=t[i].substring(0,4);
if(!glbEncode[k]) {
gb2utf8_char = eval("0x"+k);
execScript("gb2utf8_char = Chr(gb2utf8_char)", "VBScript");
glbEncode[k]=escape(gb2utf8_char).substring(1,6);
}
t[i]=glbEncode[k]+t[i].substring(4);
}
gb2utf8_data = gb2utf8_char = null;
return unescape(t.join("%"));
}
function getData(){
var XMLHttpRequestObject=false;
if (window.ActiveXObject) {
try {
XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e1){
XMLHttpRequestObject = new ActiveXObject("Msxml2.XMLHTTP");
}
} else if (window.XMLHttpRequest) {
XMLHttpRequestObject = new XMLHttpRequest();
}
if(XMLHttpRequestObject){
var obj=document.getElementById("dataDiv");
obj.innerHTML='';
var date=new Date();
XMLHttpRequestObject.open("GET","http://fw.qq.com/ipaddress?q="+date,true);
XMLHttpRequestObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
XMLHttpRequestObject.onreadystatechange=function (){
if(XMLHttpRequestObject.readyState==4 && XMLHttpRequestObject.status==200){
eval(gb2utf8(XMLHttpRequestObject.responseBody));
obj.innerHTML=IPData[0] +" "+ IPData[2];
}else{
obj.innerHTML='网络链接失败';
}
}
XMLHttpRequestObject.send(null);
}
setTimeout("getData()",3000);
}
getData();
</script>
</body>
在 iE下运行正常 在火狐下报 XMLHttpRequestObject.send(null); 错误
这是为什么? 展开
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Ip</title>
</head>
<body>
<table><tr>
<td><span id="datetime"></span></td>
<td> </td>
<td><div id="dataDiv"></div> </td></tr></table>
<script type="text/javascript" language="javascript" >
function gb2utf8(data){
var glbEncode = [];
gb2utf8_data = data;
execScript("gb2utf8_data = MidB(gb2utf8_data, 1)", "VBScript");
var t=escape(gb2utf8_data).replace(/%u/g,"").replace(/(.{2})(.{2})/g,"%$2%$1").replace(/%([A-Z].)%(.{2})/g,"@$1$2");
t=t.split("@");
var i=0,j=t.length,k;
while(++i<j) {
k=t[i].substring(0,4);
if(!glbEncode[k]) {
gb2utf8_char = eval("0x"+k);
execScript("gb2utf8_char = Chr(gb2utf8_char)", "VBScript");
glbEncode[k]=escape(gb2utf8_char).substring(1,6);
}
t[i]=glbEncode[k]+t[i].substring(4);
}
gb2utf8_data = gb2utf8_char = null;
return unescape(t.join("%"));
}
function getData(){
var XMLHttpRequestObject=false;
if (window.ActiveXObject) {
try {
XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e1){
XMLHttpRequestObject = new ActiveXObject("Msxml2.XMLHTTP");
}
} else if (window.XMLHttpRequest) {
XMLHttpRequestObject = new XMLHttpRequest();
}
if(XMLHttpRequestObject){
var obj=document.getElementById("dataDiv");
obj.innerHTML='';
var date=new Date();
XMLHttpRequestObject.open("GET","http://fw.qq.com/ipaddress?q="+date,true);
XMLHttpRequestObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
XMLHttpRequestObject.onreadystatechange=function (){
if(XMLHttpRequestObject.readyState==4 && XMLHttpRequestObject.status==200){
eval(gb2utf8(XMLHttpRequestObject.responseBody));
obj.innerHTML=IPData[0] +" "+ IPData[2];
}else{
obj.innerHTML='网络链接失败';
}
}
XMLHttpRequestObject.send(null);
}
setTimeout("getData()",3000);
}
getData();
</script>
</body>
在 iE下运行正常 在火狐下报 XMLHttpRequestObject.send(null); 错误
这是为什么? 展开
展开全部
您好,感谢您对火狐的支持
简单修改后如下:
t=t.split("@");
var i=0,j=t.length,k;
while(++i<j) {
k=t[i].substring(0,4);
if(!glbEncode[k])
{
gb2utf8_char = eval("0x"+k);
execScript("gb2utf8_char = Chr(gb2utf8_char)", "VBScript");
glbEncode[k]=escape(gb2utf8_char).substring(1,6);
}
t[i]=glbEncode[k]+t[i].substring(4);
您可以在火狐官方网站下载火狐浏览器,在火狐社区了解更多内容。希望我的回答对您有所帮助,如有疑问,欢迎继续在本平台咨询。
简单修改后如下:
t=t.split("@");
var i=0,j=t.length,k;
while(++i<j) {
k=t[i].substring(0,4);
if(!glbEncode[k])
{
gb2utf8_char = eval("0x"+k);
execScript("gb2utf8_char = Chr(gb2utf8_char)", "VBScript");
glbEncode[k]=escape(gb2utf8_char).substring(1,6);
}
t[i]=glbEncode[k]+t[i].substring(4);
您可以在火狐官方网站下载火狐浏览器,在火狐社区了解更多内容。希望我的回答对您有所帮助,如有疑问,欢迎继续在本平台咨询。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询