Firefox 中有 XDomainRequest 等效项吗?

发布于 2024-07-18 03:37:38 字数 97 浏览 4 评论 0原文

Firefox 或任何其他浏览器中是否有与 Internet Explorer 的 XDomainRequest 等效的功能?

我想访问我的域之外的服务/网站。

Is there an equivalent to Internet Explorer's XDomainRequest in Firefox or any of the other browsers?

I'd like to access a service/website outside of my domain.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

宛菡 2024-07-25 03:37:38

Internet Explorer 8 中的 XDomainRequest 对象是一种专有方法,用于请求“同源策略”之外的资源。

Firefox 3.5+ 和 Safari 4+ 允许通过 XMLHTTPRequest 对象进行跨域请求。 支持 XMLHTTPRequest Level 2 的用户代理必须具有跨源资源共享支持 (CORS),如果资源声明可以从其他域请求它,则允许检索资源。

请记住,在合规的用户代理检索资源之前,资源必须将自身声明为跨源资源。

更多信息请点击这里:
http://www.w3.org/TR/cors/
位于 W3C 网站上的 /TR/XMLHttpRequest2

The XDomainRequest object in Internet Explorer 8 is a proprietary method for requesting resources which are outside the "same-origin policy."

Firefox 3.5+ and Safari 4+ allow cross-domain requests through the XMLHTTPRequest object. User agents that support XMLHTTPRequest Level 2 must have Cross-Origin Resource Sharing support (CORS), which allows retrieving the resource IF the resource announces that it can be requested from other domains.

Keep in mind that the resource must declare itself as a cross-origin resource before a compliant user agent will retrieve the resource.

More info here:
http://www.w3.org/TR/cors/ and
at /TR/XMLHttpRequest2 on the W3C website.

没有你我更好 2024-07-25 03:37:38

有可能,您只需在目标服务器上设置跨域标头即可。

.htaccess 示例:

Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Headers "X-Requested-With"
Header set Access-Control-Max-Age "60"

XmlHttpRequest 将向目标服务器提交 OPTIONS 请求,目标服务器将使用这些标头进行响应,从而允许客户端提交预期的请求。

来源:
http://www.oriontransfer.co.nz/blog /2011-05/跨域-ajax/index

It's possible, you just have to set Cross-Domain headers at the target server.

.htaccess example:

Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Headers "X-Requested-With"
Header set Access-Control-Max-Age "60"

XmlHttpRequest will submit an OPTIONS request to the target server which will respond with those headers, allowing the client to submit the intended request.

Source:
http://www.oriontransfer.co.nz/blog/2011-05/cross-domain-ajax/index

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文