使用ExternalInterface打开浏览器窗口,然后在其中编写HTML
我可以使用 ExternalInterface.call()
中的 window.open()
打开一个新窗口,但随后我希望能够将内容写入新窗口。由于我无法从 window.open()
调用中获取窗口的引用,因此一旦窗口打开,我就无法对其执行任何操作。
请注意:我无法控制显示 swf 的 HTML。
以前有人遇到过这种情况吗?
更新:经过几个小时的反复试验,我发现您可以通过全局存储窗口引用并在需要访问新窗口时引用相同的全局引用来摆脱这种情况。
I can open a new window using window.open()
in ExternalInterface.call()
but then I want to be able to write contents to the new window. Since, I cannot get the reference of the window back from window.open()
call, I am not able to do anything to the window once it is opened.
Please note: I do not have any control over the HTML in which my swf is displayed.
Has anyone been in this situation before?
Update: After a few hours of trial and error I found you can get out of this situation by storing your window reference globally and referring to the same global reference whenever you need to access the new window.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否想简单地从 .swf 中呈现一个新网页?如果是这样,则不需要外部接口。你可以简单地使用navigateToURL:
但是,如果你想制作一个具有自定义大小和浏览器工具栏和滚动条可见性的弹出窗口,你可以像这样调用外部接口:
are you trying to simply present a new webpage from your .swf? if so, external interface is not required. you can simply use navigateToURL:
however, if you want to make a popup window with a custom size and visibility of the browser toolbar and scrollbars, you can call external interface like this:
如果您存储 javascript 窗口引用变量的名称,这是可能的。但是,您可能需要考虑这样一个事实:如果您对显示 swf 的 HTML 没有任何控制权,则无法确定 javascript 访问不会抛出
SecurityError
基于 Flash 团队制定的各种安全策略。It is possible if you store the name of the javascript window reference variable. But, you might want to consider the fact that if you don't have any control over the HTML where the swf is displayed, you can't be sure that the javascript access won't throw a
SecurityError
based on various security policies laid out by the flash team.