Karim
Karim

Reputation: 18597

Open URL from within a javascript-based Adobe AIR app

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')">Click here</a>
 ....

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

Upvotes: 0

Views: 1978

Answers (2)

Brian Sage
Brian Sage

Reputation:

(ignore my previous edit :P )

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

I hope that works for you. Worked for me.

Upvotes: 0

jimyi
jimyi

Reputation: 31191

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.

Upvotes: 1

Related Questions