views:

583

answers:

2

I've got an adobe AIR application that is written entirely in HTML/Javascript (no Flash). It's mostly self-contained but there's a single link that is meant to open a url in the user's default browser. Instead, it opens it in a separate AIR browser window. How can I go about forcing AIR to open the link in the user's default browser?

In looking around, I've seen reference to this method:

 air.navigateToURL

(http://livedocs.adobe.com/labs/air/1/jslr/flash/net/navigateToURL.html)

Which I've tried:

 navigateToUrl: function(url) {
    var request = new air.URLRequest(url);
try {            
        air.navigateToURL(request);
  return true;
    }
    catch (e) {
        return false;
    }    
 },

 ....

 <a href="#" onclick="Utilities.navigateToUrl('http://google.com')"&gt;Click here</a>
 ....

But it has no effect (no response from AIR and no browser opened).

+1  A: 

If you remove this line, it should work:

request.data = variables;

variables doesn't look like it's defined in the scope of the navigateToUrl function.

jimyi
Thanks. That made it into my demo code but isn't in the executing code. But thanks for the edit. I've updated the question.
Karim
I've copy/pasted the code that you have, and it works for me. Are there no messages in the AIR console?
jimyi
Really? Yeah, no messages. I guess there's something else going on with my code. Thanks for taking the time to check it out.
Karim
A: 

(ignore my previous edit :P )

onclick = function(){
  air.navigateToURL( new air.URLRequest('http://google.com') );
}

I hope that works for you. Worked for me.