使用 DHTML HTC 的跨域 JavaScript
我有一个典型的跨域设置。
site1.company.com
site2.company.com
主应用程序在 site1.company.com 上运行。尝试在 site1 的父框架和 site2 的子框架之间进行通信
站点 1 和站点 2 都设置 document.domain='company.com';
双向通信工作正常,但是由于同源策略,site1 的父框架不再能够与 site1 应用程序的其余部分进行通信。我向 site1 中的每个网页添加了相同的 document.domain 属性。
我现在面临的问题是我们所有 20 个 HTC 文件都不再起作用。我尝试在 HTC 的脚本标记中设置 document.domain,但这引发了访问被拒绝的消息。
尝试在没有 document.domain 的情况下使用 HTC 会导致同源策略失败,并且 HTC javascript 调用会抛出访问被拒绝的错误。
我需要做一些特殊的事情才能在 HTC 文件中启用 document.domain 吗?这还可以吗?
I have a typical setup for cross domain.
site1.company.com
site2.company.com
Main application is running off of site1.company.com. Trying to get communication working between the a parent frame from site1 and child frame from site2
Both site 1 and site 2 are setting document.domain='company.com';
The communication works fine both ways, However the parent frame from site1 was no longer able to communicate with the rest of the site1 application due to the same origin policy. I added the same document.domain property to every web page in site1.
The issue I am now facing is all of our 20 some HTC files are no longer functioning. I attempted to set the document.domain in the script tag on the HTC's but this threw an access denied message.
Trying to use the HTC's without the document.domain results in the same origin policy failing and HTC javascript calls are throwing access denied.
Is there something special I have to do to enable document.domain in an HTC file? Can this even be done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看http://easyxdm.net/,它将使您能够嵌入可以自由交流的框架并安全地跨越域边界。
它可能比处理 document.domain 更容易(导致各种问题)。
这很可能在 HTML 和 HTC 之间不起作用,但在不同域的页面之间却可以。
Take a look at http://easyxdm.net/, it will enable you to embed frames that you can communicate freely and securely with across the domain boundary.
It will probably be easier than mucking about with document.domain (causes all sorts of issues).
This will most likely not work between HTML and HTC's, but it will between pages on the separate domains.