1 Reply Latest reply on Dec 29, 2009 5:01 AM by jshrek

    How to open default browser from AJAX javascript?

    jshrek Level 1

      Is there a way to open the systems default browser from AIR using only HTML/JavaScript?


      I have tried the A tag within the html, like this:

      <a href="http://www.mydomain.com" target="_blank">www.mydomain.com</a>


      But the problem is that it simply opens up a new AIR window with no address bar.


      I need it to open an actual instance of whatever the default browser on the system is... it cannot assume one specific browser.


      The AIR window would be ok if it were possible to add a few buttons (like Back, Refresh, Stop & Home) and an Address Bar, but do not know how to do that!



        • 1. Re: How to open default browser from AJAX javascript?
          jshrek Level 1

          I am still using Air 1.5.3 but while I was browsing some pre-release documents for Air 2, I came across the following, and it works in Air 1.5:



          So the answer is simply this:

          var url = "http://www.adobe.com"; 
          var urlReq = new air.URLRequest(url);


          This will open a real browser window (not an Air window) for your URL.


          This works on my computer which is Firefox with Windows XP Pro.


          So I added a new function to my JavaScript:

          //Open a URL in a new default browser window
          function openBrowser(_url) {
            var _urlReq = new air.URLRequest(_url);


          And did this in the HTML:

          <a href="#" onclick="openBrowser('http://www.adobe.com');">www.Adobe.com</a>