跨域错误

发布于 2024-07-16 09:41:07 字数 15 浏览 2 评论 0原文

什么是跨域错误?

What is a cross-domain error?

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

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

发布评论

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

评论(2

深海不蓝 2024-07-23 09:41:07

当 Javascript(大部分时间)尝试访问不应该访问的内容时,就会发生这种情况。

例如,如果您尝试读取另一个域的 cookie,那将不起作用。 如果您尝试向另一个域或协议(HTTP > HTTPS)发出 XMLHTTP 请求,则该请求将不起作用。 因为如果你能做到这一点,你就可以劫持、窃取其他网站上的访问者会话。

它是安全功能,现在它是所有浏览器的标准。

It happens when Javascript (most of the time) try to access something which it shouldn't.

Such as if you try to read another domain's cookie, that won't work. If you try to do XMLHTTP request to another domain or protocol (HTTP > HTTPS) that won't work. Because if you can do that you can hijack, steal your visitors session in other websites.

It's security feature and now it's a standard in all browser.

古镇旧梦 2024-07-23 09:41:07

据我了解,当您尝试连接到服务器时,Silverlight(可能还有 Flash/Javascript)等客户端工具会抛出跨域错误,而该连接通常仅在连接到与服务器相同的域时才允许。页面由(某些来源策略)提供。

例如,当您在测试服务器上查看页面时,当测试服务器尝试调用实时服务器时,或者当您使用 file:// 将测试页面作为本地文件查看时,可能会引发跨域错误。协议。

尝试确保您正在测试的域与网站设计的域相同。 请注意,Flash 具有 crossdomain.xml 功能,专门允许您执行跨域请求。 JavaScript 也有办法绕过同源策略,但你应该意识到你正在做的事情的影响。

As I understand it, client-side tools such as Silverlight (and maybe Flash/Javascript) throw a cross-domain error when you attempt to make a connection to a server that is normally only allowed when it is made to the same domain that the page was served from (some origin policy).

A cross-domain error may be thrown when, for example, you are viewing a page on your test server when it is trying to call your live server, or when you are viewing a test page as a local file using a file:// protocol.

Try ensuring that the domain you are testing on is the same as that which the site was designed to be on. Note that Flash has the crossdomain.xml feature which specifically allow you to do cross-domain requests. Javascript also has ways to get around same origin policy, but you should be aware of the implications of what you're doing.

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