Solution for HTML pop-up problem in AIR

24 04 2008

From the past few days, I’m seeing a problem with AIR HTML Component that is being reported by many users in many forums. So, i thought of giving a small solution which will help developers to overcome this problem.


AIR HTML Component fails to open new HTML pop-up window when the “target” of the link is set to “_blank” or “_new”.


The solution is very straight and simple.

Step 1 – Get all the available links of the page after it is completely loaded and add “onClick” event listener to all required links.

Step 2 – Get the Link’s URL in “onClick” event handler and open a new browser window using “navigateToURL()” or implement a custom window in AIR to handle this.


<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="" layout="absolute">
<mx:HTML id="htmlComp" width="100%" height="100%" location="" complete="addEventListenersToLinks(event)"  />
   private function addEventListenersToLinks(e:Event):void
    var dom:Object = e.currentTarget.domWindow.document;
    var links:Object = dom.getElementsByTagName("a");
    for(var i:Number = 0; i < links.length; i++)
     if(links[i].target.toLowerCase() == "_blank" || links[i].target.toLowerCase() == "_new")
      links[i].onclick = linkClickHandler;
   private function linkClickHandler(o:Object):void
    navigateToURL(new URLRequest(o.currentTarget.href),"blank");




9 responses

17 07 2008

Hello Srinivas,

thx a lot for your turn around !
it helped me to solve this problem I had too with some “area shape” in an html page.

have a good day !

22 07 2008

That’s brilliant.
Thank you, for your work

24 07 2008

Thank you so much! Finally a helpful blog.

12 03 2009

you just save my life, thx!

29 04 2009
Dean Cadwallader

GREAT! any way to launch the ‘new’ or ‘blank’ window within the HTML component itself, say in a new tab perhaps (rather that in the users default browser)?

Many thanks for a great solution 🙂

20 06 2009


Thanks for a great post! I’m trying to load a .swf file instead of an html page but can’t get the domWindow property. Do .swf files have an equivalent domWindow property?

Many thanks 🙂

22 06 2009

There is no DOM available inside SWF file.

But, if you want to parse through the hierarchy of the components inside your Flash Application, you can use ActionScript properties like “numChildren” property and “getChildAt(index)” API inside your SWF file.

2 11 2009
Guilherme Henrique

Thank you for your Post, simple and functional… TY

4 01 2010

Nice and simple, worked for me.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: