AIR HTML控件问题(它没有打开具有属性target =“_ blank”的链接)

问题描述 投票:2回答:1

我开发了Adobe AIR应用程序,它可以在HTML控件中打开网站的cpanel。我意识到HTML控件打开链接在同一个窗口打开,但它不会打开在新窗口中打开的链接,即具有属性(target =“_ blank)的链接,如下所示:

<a href"" target="_blank"> Opens in new window </a>

我在网上搜索过,虽然我在这里有一个解决方案AIR HTML with “_blank” Links,但它打开了浏览器中的链接,而且它太旧了(2008年9月)。那么,有谁知道打开链接的另一种简单方法?

actionscript-3 air flash-builder flashbuilder4 flash-cs5
1个回答
2
投票

我重写了你发现改变锚目标的例子,现在链接在同一个窗口中打开。但是这种方法有局限性 - 只修复了静态链接,试图在新窗口中打开链接的任何JS方法都将失败。

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication
    xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
    initialize="init()">
<mx:Script>
<![CDATA[
    private function init():void
    {
        html.htmlText =
            "<html><body>" +
            "<a href='http://adobe.com' target='_blank'>Adobe (blank)</a><br/>" +
            "<a href='http://ixbt.com' target='_self'>iXBT (self)</a>" +
            "</body></html>";
        html.addEventListener(Event.COMPLETE, onHTMLComplete);
    }

    private function onHTMLComplete(event:Event):void
    {
        var document:Object = html.domWindow.document;
        for each (var anchor:Object in document.getElementsByTagName("a"))
        {
            if (anchor.hasOwnProperty("target"))
            {
                if (anchor.target == "_blank")
                {
                    anchor.target = "_self";
                }
            }
        }
    }

]]>
</mx:Script>
    <mx:HTML id="html" width="100%" height="100%"/>
</mx:WindowedApplication>
© www.soinside.com 2019 - 2024. All rights reserved.