试图通过302从一台服务器重定向到另一台没有内容的服务器,仅用于跟踪目的,我担心会丢失一些使用Apple iOS设备的访问者, Webkit/Chrome浏览器。AJAX:301/302头部重定向(跨域)在某些Webkit浏览器中失败
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的/镀铬/移动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到达,停止没有错误或警告。
这只是发生跨域重定向头,是否有额外的头允许这样做?
2013-04-03
ledy