尝试通过302重定向从一个服务器跳转到另一个服务器,仅用于跟踪目的,我担心在苹果iOS设备和一些Webkit / Chrome浏览器上会丢失一些访问者。
在Firefox和IE上,重定向是正常的。从domainA到domainA的重定向也是正常的。在Webkit/Chrome/Mobile Safari浏览器上,跨域重定向失败 :-(
javascript代码段如下:
无论在iPhone、iPad设备和Chrome上,我记录了流量,但它从未到达target2.com,也没有任何错误或警告提示。
这仅发生在跨域头部重定向时。是否有其他的头文件可以允许此操作?
HTTP/1.1 302 Moved Temporarily
Date: Tue, 26 Mar 2013 20:00:03 GMT
Server: Apache/2.2.3 (Red Hat)
X-Powered-By: PHP/5.2.6
Expires: Tue, 03 Jul 2001 06:00:00 GMT
Last-Modified: Tue, 26 Mar 2013 20:00:03 GMT
Cache-Control: no-store
Pragma: no-cache
P3P: CP="STP CUR OUR"
x-own: 46.163.123.40
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Location: http://target2.com
Connection: close
Content-Type: text/html; charset=iso-8859-1
在Firefox和IE上,重定向是正常的。从domainA到domainA的重定向也是正常的。在Webkit/Chrome/Mobile Safari浏览器上,跨域重定向失败 :-(
javascript代码段如下:
testRedirection=function(url)
{
var xmlhttp = null;
if (window.XMLHttpRequest)
xmlhttp=new XMLHttpRequest();//ff,webkit
else if (window.ActiveXObject)
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");//ie
if(xmlhttp)
{
xmlhttp.open("HEAD",url,true);//tried HEAD, GET, POST
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4)
{
if(xmlhttp.status==200 || (xmlhttp.status>200 && xmlhttp.status<400))
alert("arrived with status "+xmlhttp.status);
else
alert("failed with status "+xmlhttp.status);
};
};
xmlhttp.send();
};
//\
};
无论在iPhone、iPad设备和Chrome上,我记录了流量,但它从未到达target2.com,也没有任何错误或警告提示。
这仅发生在跨域头部重定向时。是否有其他的头文件可以允许此操作?