配置firefox允许ajax跨域请求

  默认firefox中ajax是不允许跨域请求数据的,要想firefox下ajax允许请求跨域,有2中方法。

  第一种,修改firefox配置,将signed.applets.codebase_principal_support项目为true(默认为false)。firefox的地址栏中输入“about:config”,并找到signed.applets.codebase_principal_support,将其设为true,如下下图所示

配置firefox允许ajax跨域请求

但这种方法经过实现,仍然无法访问其他域的url,不知是不是新版的firefox把这个给屏蔽了。就算这种方法可行,也尽量不使用这种需要配置firefox的方法,而要使用编程的方法,在访问其它域之前,可以使用如下代码打开权限:

try  {
      netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");  
} 
catch (exception) { 
     alert(exception); 
 }

要注意的是,上面的代码只能用在firefox中,因此,要将其放到只有firefox才能执行到的代码块中,如在下面的块中:

if(navigator.userAgent.indexOf('Firefox')!=-1) {  // firefox        
    try { 
        netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); 
    }
    catch (exception) { 
        alert(exception); 
    }
}

来源:http://www.cnblogs.com/nokiaguy/archive/2008/05/15/1198604.html

参考:

chrome完全取消同源访问策略控制

IE7+浏览器下XMLHttpRequest跨域请求安全配置

加支付宝好友偷能量挖...


评论(0)网络
阅读(1147)喜欢(0)操作系统及应用软件