使用ExternalInterface打开浏览器窗口,然后在其中编写HTML

发布于 2024-10-01 01:52:58 字数 294 浏览 0 评论 0原文

我可以使用 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 技术交流群。

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

发布评论

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

评论(2

若相惜即相离 2024-10-08 01:52:58

您是否想简单地从 .swf 中呈现一个新网页?如果是这样,则不需要外部接口。你可以简单地使用navigateToURL:

navigateToURL(new URLRequest("http://www.stackoverflow.com"), "_blank");

但是,如果你想制作一个具有自定义大小和浏览器工具栏和滚动条可见性的弹出窗口,你可以像这样调用外部接口:

if (ExternalInterface.available)
   {
   ExternalInterface.call(
                         "window.open",
                         "http://www.stackoverflow.com",
                         "win",
                         "height=200, width=300, toolbar=no, scrollbars=yes"
                         );
   }

are you trying to simply present a new webpage from your .swf? if so, external interface is not required. you can simply use navigateToURL:

navigateToURL(new URLRequest("http://www.stackoverflow.com"), "_blank");

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:

if (ExternalInterface.available)
   {
   ExternalInterface.call(
                         "window.open",
                         "http://www.stackoverflow.com",
                         "win",
                         "height=200, width=300, toolbar=no, scrollbars=yes"
                         );
   }
冷夜 2024-10-08 01:52:58

如果您存储 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.

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