跨子域 iframe 和 JavaScript
我正在一个 CMS 站点上工作,其域是:
http://www.acmssite.com
他们有一个存储表单系统的子域:
http://www.forms.acmssite.com
我在第一个站点上有一个 iframe,它查看后者中的表单。
我需要运行脚本来从前者操纵后者,并且想知道这可能吗?
I am working on a CMS site whose domain is:
http://www.acmssite.com
They have a sub-domain where they store a form system:
http://www.forms.acmssite.com
I have an iframe on the first that looks at a form in the latter.
I need to run scripts to manipulate the latter from the former and was wondering is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为了不受同源策略的限制,您可能需要在两个页面中执行此操作:
In order for this to not be restricted by the same origin policy, you will probably need to do this in both the pages:
是的。
Yes it is.
即使您无权访问接收窗口的标头部分,您仍然可以借助 YQL 绕过此问题。使用 Postmessage 方法,您还需要编辑收件人窗口脚本。但使用这种方法,您可以加载任何 iframe,而无需触及其脚本。看看这个! jsfiddle-link
You can still bypass this issue with the help of YQL even though you don't have access to the header part of the receiving window. With the Postmessage method also you need to edit the recipient window script. But using this method you can load any iframe without touching their scripts. Check this out! jsfiddle-link