1 Reply Latest reply on May 11, 2009 10:47 AM by soltrinox1

    Problem opening links from remote website

    soltrinox1 Level 1

      I have tried the example at :


      http://livedocs.adobe.com/labs/air/1/jslr/flash/net/URLRequest.html#method

       

      <html>
          <head>
            <script src="AIRAliases.js" />
            <script>
      function init() {
                  var url = "http://www.mydomain.com/client.php";
                  var request = new air.URLRequest(url);
                  air.navigateToURL(request);
      }

      var addBridge = function(){
           document.getElementById('child').contentWindow.parentSandboxBridge = interfaceObject;
           window.runtime.trace('js bridge call');
      }
      </script>
          </head>
          <body onload='init()'>
      <a href="#" id="child" onClick="clickButton();">link to open web browser</a>
          </body>
      </html>

       

      But i can not seem to make links in html loaded from remote domain in mx:HTML component open a default browser.

      Has anyone done this?This code is running in the html of the remote page loaded inside of the following air application.

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
          showFlexChrome="false" showStatusBar="false" showGripper="true" showTitleBar="false"
          width="408" height="710" frameRate="45"
          horizontalScrollPolicy="off" verticalScrollPolicy="off"
          xmlns:chrome="com.xd.components.chrome.*"
          xmlns:sync="com.xd.components.sync.*"
          xmlns:controlbar="com.xd.components.controlbars.*"  viewSourceURL="srcview/index.html"
          applicationComplete="init()"
          >

       

          <mx:Style source="assets/dark_default.css" />
         
      <mx:Script><![CDATA[
      import flash.net.URLRequest;
             
      public function clickButton():void{
      var request : URLRequest = new URLRequest('http://www.mydomain.com/client.php');
      navigateToURL(request )   

       

      private var testInterface:Object = new Object();

       

      private function init():void
      {
      testInterface.clickButton = this.clickButton;
      }

       

      private function addBridgeObject():void
      {
      trace("Added bridge object");
      html.domWindow.interfaceObject = testInterface;
      }


      ]]></mx:Script>

          <!-- Application Custom Chrome -->
          <chrome:CustomChrome top="10" bottom="10" left="10" right="10" />
         
          <!-- ContentBackgroundArea -->
          <mx:VBox top="11" bottom="11" left="11" right="11" styleName="contentBackground" horizontalScrollPolicy="off" verticalScrollPolicy="off" >
             
          </mx:VBox>
         
          <!-- ContentArea -->
          <mx:Canvas visible="true" top="66" bottom="34" left="11" right="11" styleName="contentArea" horizontalScrollPolicy="off" verticalScrollPolicy="auto" >
              <chrome:BorderHighlight top="0" bottom="0" left="0" right="0" />
              <mx:Button click="clickButton()" />
      <mx:HTML id="html" location="http://www.mydomain.com/client.php" htmlDOMInitialize="addBridgeObject()" width="100%" height="100%"/>
          </mx:Canvas>

       

          <!-- Application ControlBar -->
         
          <!-- Application StatusBar -->
          <chrome:StatusBar bottom="11" left="11" right="11" />
         
      </mx:WindowedApplication>

       

      How can i get the links in the remote webpage to open the default system browser  (firefox, IE, etc..) ?

      I get the following error on line 7 of the loaded html page in the debugger.


      TypeError: Undefined value


      i think this means that the value is not defined?  or cant access the function

      air.URLRequest


      Which is declared in the AIRAliases.js file for sure i checked.
      also when clicking the hyper link in the page i get


      ReferenceError: Can't find variable: clickButton

       

      TIA,

       

      soltrinox

        • 1. Re: Problem opening links from remote website
          soltrinox1 Level 1

          Set the navigateInSystemBrowser property of the HTMLLoader control on the creationComplete event of the HTML control.

          Explanation

           

          Source

          <?xml version="1.0" encoding="utf-8"?>
          <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
          <mx:Script>
                <![CDATA[
                      private function init():void
                      {
                            html.htmlLoader.navigateInSystemBrowser = true;
                      }
                ]]>
          </mx:Script>
                <mx:HTML location="test.html" id="html" creationComplete="init()"/>
          </mx:WindowedApplication>

          Caveat


          Changes to the location property of the HTML control will now cause the link to open up in the system browser. The fix for that is to set the htmlLoader.navigateInSystemBrowser property to false, change location and then set it back to true.