ExternalInterface 将值从 swf 传递到同一页面上的 iFrame
在一个页面上,我有一个 iFrame 和一个 swf,我一直在尝试使用ExternalInterface 将值从 swf 传递到 iFrame,有人尝试过这个并且运气好吗?直到明天我才能发布任何代码,如果需要的话我会更新。
提前致谢。
这是我需要完成的任务的可视化,也许如果不能按照我所说的方式完成,有人会建议另一种方法来完成此任务。
On a page I have a an iFrame and a swf, I've been trying to use ExternalInterface to pass values from the swf to the iFrame, anyone ever tried this and had any luck? I won't be able to post any code until tomorrow, will update then if needed.
Thanks in adavnce.
Here is a visualization of what I need to accomplish, perhaps if it can't be done the way I said someone will have a suggestion of another way to accomplish this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试瞄准框架。这应该适用于页面上的一帧,否则您将不得不更改索引。
如果这对您不起作用,请使用 LocalConnection 并将隐藏的 swf 放在 iframe 文件上。
LocalConnection 对于浏览器来说是全局的,因此请注意,如果打开两个浏览器窗口,您将获得两个使用相同名称连接的 iframe,并且会得到一些奇怪的结果。
因此,请通过查询字符串和 flashvars 更改连接名称。
这是一个真正的黑客解决方法,但它会起作用。
[编辑]
另一件事是确保您的 javascript 回调函数被调用,因为当在文件结构下而不是在域中运行时,ExternalInterface 存在重大域问题(例如:在编辑器中单击运行)。尝试上传到您的服务器并更改您的嵌入代码以允许它。另外不要忘记更新您的 crossdomain.xml。
Try to target the frame. This should work with one frame on the page or you will have to change the index.
If this doesn't work for you then use LocalConnection and put a hidden swf on the iframe file.
LocalConnection is Global to the browser so be aware that if two browser windows are open you will get two iframes connecting on the same name and will get some funky results.
So change the connection name via query string and flashvars.
Its a real hackish workaround but it will work.
[EDIT]
One more thing make sure your javascript callback function is getting called as ExternalInterface has major domain issues when running under the file structure and not in a domain(EX: clicking run in the editor ). Try uploading to your server and change your embed code to allow for it. Also dont forget to update your crossdomain.xml(s).
您无法从 iframe 外部访问它们。这些都是安全原因,浏览器将并且应该阻止此类尝试。
You cannot access iframes from outside of them. These are security reasons, and browsers will and should block such attempts.