3 Replies Latest reply on Aug 31, 2009 9:03 AM by scholarpack

    Javascript popups in an AIR HTML component

    Dan McAdam Level 1

      Hey everyone...

      I'm on a continuing quest to develop a simple HTML editor inside a Flex / Flash / AIR runtime. My latest attempt was going really well until i tried to use the editor menu buttons, which generated an AIR Alert that said:

       

      "Sorry, but we have noticed that your popup-blocker has disabled a window that provides application functionality. You will need to disable popup blocking on this site in order to fully utilize this tool."

       

      which is from the javascript editor program

       

      I'm using tinyMCE, set up on my localhost dev machine, and calling it from an HTML string which is loaded from a database into an AIR HTML component inside the AIR application (and using a <script src='http://localhost/scriptfolder/scriptname' type='text/javascript'> in the HEAD section of the HTML doc). I get the HTML content to display, and the tinyMCE editor also is in place... but whenever I try to use a menu button on the tinyMCE interface that requires a popup dialog... i get an alert with the notice mentioned above..

      However, the tinyMCE editor does work on the loaded HTML for other functions, like making text bold or underlined etc... just not the popup dialogs, like Insert Image.

       

      I've read all the documentation on sandboxes and using Javascript inside AIR HTML components, but must confess, I don't understand how to set up the sandboxes correctly.

       

      I tried setting

      MyHTMLComponent.htmlLoader.placeLoadStringContentInApplicationSandbox = true;

      but then the tinyMCE editor doesn't appear at all.

       

      does anyone know if its possible to configure the AIR runtime to allow window.open operations from a javascript inside an AIR HTML Component  ?

       

      thanks

      Dan McAdam

      Salem, Oregon

        • 1. Re: Javascript popups in an AIR HTML component
          scholarpack

          I think your issue is getting the popup to open in the first place. It took me a while to figure that one out. To sort it I put the following in my Air apps source and then called it on 'creationComplete':

          The mx:HTML has the id of 'minibrowser'

           

          <mx:Script>
                  <![CDATA[
                      private function init():void {
                          minibrowser.location = "http://somewherenice.com";
                          var defaultHost:HTMLHost = new HTMLHost(true);
                          minibrowser.htmlHost=defaultHost;
                      }
                  ]]>
              </mx:Script>

           

          This got the popups to work for me but SWF does not show in them.

          • 2. Re: Javascript popups in an AIR HTML component
            Dan McAdam Level 1

            thanks for the input...

             

            where is the HTML document you're loading coming from ?

             

            i think my issue is related to the 'application sandbox' vs the 'remote

            sandbox' (although i really don't understand the sandbox assignments in

            Flex)

             

            the HTML i'm loading is coming in from remote procedure call against a PHP /

            MySQL backend... i insert the javascript code into that HTML that links and

            calls the tinyMCE editor libraries... which are in a separate location. The

            problem seems to be in that, while the HTML and javascript works fine until

            the javascript tries to open a popup window (window.open)... that's when the

            Flex framework silently stops the window.open call and the tinyMCE scripts

            think its a popup blocker.

             

            I'll try your solution and set the HTML component's location property and

            assign a new default HTMLHost object to it before i run it...

             

            looks like you're doing some kind of E-Learning applications ?... i did a

            bunch of elearning development over the past 5 years or so (mostly using

            Flash in a SCORM based Learning Mangement System)

             

            thanks again.. i'll let you know what i find.

             

            best

            Dan McAdam

            Salem, Oregon

            • 3. Re: Javascript popups in an AIR HTML component
              scholarpack Level 1

              I don't think you need to set the location, I only copy/pasted from my app.