3 Replies Latest reply on Jul 30, 2010 5:32 AM by Mihai Balan

    Javascript in Adobe air

    stan801003a

      Hi I have an online order form page whcih uses javascript/ ajax to auto look up the database, the page works fine as a webpage, what i am trying to do is to add the page to Adobe air so that it can be used as a standalone page on a desktop to allow customers to order products using our catalogue and without having to go to the website.

       

      However whilst the page seems to display fine it doesn't show the javascript/ajax auto look up suggestion list, that appears when you start typing and wondered if there was anyway i could get the list to display or if Adobe air will allow me to load a page with Javascript and ajax wihtin it.

       

      Thanks

       

      Stan

        • 1. Re: Javascript in Adobe air
          Mihai Balan Adobe Employee

          Hi Stan,

          Could you please be more specific as how your JavaScript/AJAX webpage is fetching and displaying the search suggestions? The kind of use-case you're presenting here is actually possible and has been implemented in many AIR applications.

           

          However, from what you describe, it seems to me like the code in your webpage is trying to do things that are not allowed by AIR's security model. This (among other things) prohibits the use of eval() (for converting JSON to actual JavaScript objects, too), of javascript:/ URIs and inline event handlers.

           

          Hope this helps,

          Mihai

          • 2. Re: Javascript in Adobe air
            stan801003a Level 1

            Hi ,

             

            Thanks for your answer, To be perfectly honest i am not a javascript or jquery programer on relly only know the basics as the code i am using was built on a tutorial.  However the page uses a lookup function which then uses a php page to look up the database query.

             

            Here Is a link to the page  http://95.131.66.39/~pestcont/autosearch/form_new.html

             

            If the page doesnot support the javascript in the page is there another way i can do this.

             

            thanks

            • 3. Re: Javascript in Adobe air
              Mihai Balan Adobe Employee

              Hi Stan,

              I played a little with the page you gave me and I found the problem. When performing a lookup the server returns HTML content that contains JavaScript. As per the security model in the application sandbox, AIR will not allow you to add that HTML. Thus, the suggestions will not display at all.

              You can find more about AIR development with HTML/JavaScript at http://help.adobe.com/en_US/air/html/dev/index.html . Specifically the Security chapter ( http://help.adobe.com/en_US/air/html/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7d23.html ) might be of interest to you.

               

              As for work-arounds to your problem, I can see two:

              • Run the page in an iframe that's in the remote sandbox. Note however that in this case you will not be able to use AIR specific APIs in the page
              • Modify the server code to return the suggestions in some other format (e.g. XML) and parse the response on the client. Then programatically add the needed HTML elements and event handlers. Note that if you want to add JavaScript, you still won't be able to use eval, or inline handlers (as is the case with code currently returned from the server, like

                <li onClick="fill1('  ANTSTOP  Pk 2');fill2('  Ant Stop Bait Station, HSE 7294(Registered for ama'); ..."></li> ) The code in red is the one that's not allowed by the security policy.

                 

                Feel free to ask if you have any other questions.


                Mihai