apache-flex - window.open 在 AIR html 组件中不起作用吗?

标签 apache-flex flash air

我在 AIR 中有一个组件,如下所示:

<mx:HTML
        id="html"
        width="100%" 
        height="100%" 
        location="https://example.com" 
        locationChange="dispatchLocationChange(event)"
    />

它加载的页面包含以下内容:

<a onclick="alert('onclick')">Alert</a>
<a href="javascript:alert('js')">Alert</a>
<a onclick="window.open('http://www.google.com','_blank')">new window</a>

这两个警报都有效。但是,当您单击新窗口链接时,什么也没有发生。

所有 3 个链接在真实浏览器中都有效,所以我知道它没问题。

AIR HTML 组件中是否不支持 window.open?或者这是一个错误?

有解决办法吗?

最佳答案

我发现您需要扩展 HTMLHost 类并重写 createWindow 方法,如下所示:

override public function createWindow(windowCreateOptions:HTMLWindowCreateOptions):HTMLLoader
{
    var window:Window = new Window();
    window.open();
    window.visible = true;


    window.height = windowCreateOptions.height;
    window.width = windowCreateOptions.width;


    var htmlLoader:FlexHTMLLoader = new FlexHTMLLoader();
    htmlLoader.width = window.width;
    htmlLoader.height = window.height;
    htmlLoader.htmlHost = new MyHTMLHost();

    window.stage.addChild(htmlLoader);

    return htmlLoader;
}

然后将此子类设置为 HTML 组件的 htmlHost 属性。

这确实可以让它工作。但新的弹出窗口中有一些奇怪的行为。看起来有点问题。

关于apache-flex - window.open 在 AIR html 组件中不起作用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3047722/

相关文章:

javascript - 在 Javascript 中实现后退按钮 'Warning' 以便在 Flex 中使用

actionscript-3 - 设置swf高度和宽度时视频消失

android - 如何删除 AIR 中未经验证的服务器弹出窗口?

actionscript-3 - 当窗口没有焦点时如何从控件中移除焦点?(否则当窗口再次获得焦点时它将恢复)

java - 是否有可用于 Java、C++ 和 JS 的可下载的 eclipse 包

php - Flash、Facebook 和权限 - JS、PHP 或 AS3 SDK

javascript - 在 HTML Adob​​e AIR 应用程序中加载 Facebook ActionScript 库

ios - AS3 iOS : Loading external swf

css - 你知道这个奇怪的事情吗? "AS3, Button width cannot change by setStyle(). However, inline CSS can change width."

java - SWF转码,存在吗?