Firefox 跨域请求
我需要从在 Firefox 中运行的脚本发出跨域请求(仅用于开发目的)。
这能实现吗?也许修改 about:config
键?
谢谢!
I need to make a cross domain request from a script that runs in firefox (it's just for development purposes).
Can this be achieved? maybe modifying the about:config
keys?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
James Padolsey 发表了一篇很棒的文章,介绍了如何使用jQuery来跨域请求,但是该帖子也有非常好的资源。需要在其他服务器上进行一些调整,以允许使用 crossdomain.xml 进行跨域调用
There is a great post by James Padolsey on how to to cross domain requests using jQuery, But the post also has very good resources. There need to be some tweaking to be done on the other server to allow cross domain calls using crossdomain.xml
Opera 10.5 允许“允许跨域访问”。
Opera 10.5 allows for "Allow Cross Domain Access".
有点晚了,但我想无论如何我都会在这里发布信息;
我没有完全阅读每个人答案中的链接,但我快速浏览了一下,没有看到有人提到使用PrivilegeManager - 绕过安全限制和签名代码。使用此功能,您可以让 FireFox JavaScript 应用程序在浏览器中调用扩展安全权限的请求,包括跨域 XHR。
A little late, but thought I'd post the info here anyway;
I didn't fully read the links in everyone's answers, but I had a quick look and I didn't see that anyone mentioned using the PrivilegeManager - Bypassing Security Restrictions and Signing Code. Using this you can have your FireFox JavaScript app invoke a request for extended security privileges in the browser, including cross domain XHR.
同源政策适用于所有浏览器。使用 javascript,您可以发送 GET 和 POST 请求,但您将无法像使用 XHR 那样读取响应。 XHR 只能针对脚本执行所在的域进行。这是一条重要的规则,因为它可以防止广泛传播的跨站请求伪造 (CSRF) 漏洞。
您可以将 flash 与 crossdomain.xml 文件一起使用,我认为这是最强大的解决方案,因为它将完全满足您的需求,并且具有最佳的浏览器兼容性。
编辑:如果您希望在 Firefox 上运行特定的 JavaScript 来绕过同源策略,那么您可以构建自定义附加组件。或者跨域插件也许可以满足您的需求。
The Same Origin Policy applies to all browsers. Using javascript you can send GET and POST requests, but you will not be able to read the response like you can with XHR. XHR's can only be done against the domain the script is executing from. This is an important rule as it prevents wide spread Cross Site Request Forgery(CSRF) vulnerabilities.
You can use flash with a crossdomain.xml file and I think this is the most robust solution because it will do exactly what you need and have the best browser compatibility.
EDIT: If you want specifically JavaScript running on Firefox to bypass the Same Origin Policy then you can build a custom add-on. Or perhaps the Cross Domain add-on will do what you need.
使用 CORS 的跨站点 xmlhttprequest
cross-site xmlhttprequest with CORS
正如“The Rook”所提到的,您可以使用 Flash 执行跨域请求,前提是您正在交谈的服务器提供授予您的服务器访问权限的 XML 策略文件。如果您控制两台服务器,那么这应该很容易完成。
如果您不想自己编写任何 Flash 代码,或者希望能够通过 SSL/TLS 进行跨域,请查看开源 Forge 项目:
http://github.com/digitalbazaar/forge/blob/master/README
As mentioned by 'The Rook', you can use Flash to do cross-domain requests provided that the server you're talking to serves an XML policy file granting your server access. If you control both servers that should be easy enough to accomplish.
If you don't want to write any Flash code yourself or if you want to be able to do cross-domain over SSL/TLS check out the opensource Forge project:
http://github.com/digitalbazaar/forge/blob/master/README