开发者

AIR HTML Control Issue (it's not opening links that have attribute target = "_blank")

开发者 https://www.devze.com 2023-02-24 21:02 出处:网络
I\'ve developed Adobe AIR application, which opens cpanel of websites in HTML control. I realized that HTML control open links which opens in same window, however it don\'t opens the links that opens

I've developed Adobe AIR application, which opens cpanel of websites in HTML control. I realized that HTML control open links which opens in same window, however it don't opens the links that opens in new window i.e links which has attribute (target="_blank) like this:

&开发者_运维技巧lt;a href"" target="_blank"> Opens in new window </a>

I've searched the web, although I've got one solution here AIR HTML with “_blank” Links but it opens that links in browsers and its too much old (September 2008). So, anyone know another simple way to open link?


I rewrited example you found to change anchor target, now links are opened in same window. But this method has limitations - only static links are fixed, any JS methods trying to open link in new window will fail.

<?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>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号