gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 06:51:34 24 4
gpt4 key购买 nike

我在 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>

2 个警报都有效。但是当您单击新窗口链接时没有任何 react 。

所有 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com