2

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:

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

halfer
  • 18,701
  • 13
  • 79
  • 158
Mudasir Bhutto
  • 468
  • 1
  • 11
  • 24

1 Answers1

2

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>
alxx
  • 9,882
  • 4
  • 24
  • 40
  • Hi Alla and Alxx: I again stuck with an-other issue. If HTML page is divided into farmes, then clicking on link of frame does not reload the page, so Complete event is not triggered. So any link with target="_blank" is unable to open :(. Can you help me on this issue too? – Mudasir Bhutto Apr 20 '11 at 11:36