Skip to main content
Participating Frequently
March 28, 2013
Answered

How do I open specific links outside htmlLoader?

  • March 28, 2013
  • 1 reply
  • 1432 views

I have an Air app, which loads my website through htmlLoader, and allows users to log in and interact with it through the app. My problem is I want some links to open outside the app (ie, in the default browser) but I havn't a clue on how to do this. I've tried navigateInSystemBrowser in the htmlLoader class, but for some reason, this opens the initial page in the default browser, and leaves my app empty. Any ideas?

This topic has been closed for replies.
Correct answer kglad

yes


then you can use the dom references for your links to detect when a link is clicked and you can execute code to reload the html page (so the html-linked page doesn't load) and you can use navigateToURL.  for example:

var htmlLoader:HTMLLoader = new HTMLLoader();

htmlLoader.width = 300;

htmlLoader.height = 300;

addChild(htmlLoader);

htmlLoader.addEventListener(Event.COMPLETE, completeHandler);

htmlLoader.load(new URLRequest("http://www.kglad.com/Files/test/menu.html"));

function completeHandler(event:Event):void {

    htmlLoader.window.document.getElementsByTagName("a")[0].onclick = clickHandler;

}

var t:Timer=new Timer(1,1);

t.addEventListener(TimerEvent.TIMER,reloadF);

function clickHandler(e:Object):void{

    t.start();

    htmlLoader.removeEventListener(Event.COMPLETE, completeHandler);

    navigateToURL(new URLRequest(htmlLoader.window.document.getElementsByTagName("a")[0].href));

}

function reloadF(e:TimerEvent):void{

    htmlLoader.load(new URLRequest("http://www.kglad.com/Files/test/menu.html"));

}

1 reply

kglad
Community Expert
Community Expert
March 28, 2013

use navigateToURL.

looserlfAuthor
Participating Frequently
March 28, 2013

How do I use it. My link is on my website, which is then loaded into the app through htmlLoader. (might not've made that clear, sorry)

kglad
Community Expert
Community Expert
March 28, 2013

if the links on your website are already coded to load link targets, you shouldn't need any coding in your swf to enable that functionality. 

you might have a security sandbox issue however that would require a permissions file on your website.