配置firefox允许ajax跨域请求
默认firefox中ajax是不允许跨域请求数据的,要想firefox下ajax允许请求跨域,有2中方法。
第一种,修改firefox配置,将signed.applets.codebase_principal_support项目为true(默认为false)。在firefox的地址栏中输入“about:config”,并找到signed.applets.codebase_principal_support,将其设为true,如下下图所示
但这种方法经过实现,仍然无法访问其他域的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
参考:
IE7+浏览器下XMLHttpRequest跨域请求安全配置
加支付宝好友偷能量挖...