Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How do I open specific links outside htmlLoader?

New Here ,
Mar 28, 2013 Mar 28, 2013

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?

TOPICS
ActionScript
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 29, 2013 Mar 29, 2013

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:E

...
Translate
Community Expert ,
Mar 28, 2013 Mar 28, 2013

use navigateToURL.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 28, 2013 Mar 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)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 28, 2013 Mar 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 28, 2013 Mar 28, 2013

Sorry, I don't understand, the links open within the app already, what I want them to do is outside the app. (like in a browser) I've tried to use window.open in javascript, or "_blank" in html, and neither have worked.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 29, 2013 Mar 29, 2013

you're using htmlLoader to load an html page, correct? 

that page contains html links, correct?

those html links are encoded with anchor tags, correct?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 29, 2013 Mar 29, 2013

yes

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 29, 2013 Mar 29, 2013

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"));

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 29, 2013 Mar 29, 2013

Thanks a lot! That was exactly what I was looking for! Just one more thing though, how do I make the link only open in the browser, and not in the app aswell. (So when I click it, the url opens in the browser, but the app stays on the page it was originally on)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 29, 2013 Mar 29, 2013

that's what reloadF does.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 29, 2013 Mar 29, 2013

Oh, sorry, I just had two different urls that was the problem. Thanks so much! It's working fine!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 29, 2013 Mar 29, 2013
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines