Javascript in Adobe air

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

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

Similar Messages

  • Javascript in adobe air question...

    I have a VERY simple javascript password script that just
    takes the password from a form and compares it... if password is
    correct is redirects to correct html file. I know the script is
    poorly written, but it does what I need for the time being.
    if (form.pass.value=="password") {
    window.location="page2.html"
    } else {
    alert("Invalid Password")
    Although the script works, I can't seem to get it to redirect
    to the page2.html when the correct password is entered. If I
    replace the window.location with an alert it works so I know the
    rest of the code is working fine.
    Is there something I need to do in order to get
    window.location to work in an adobe air app? or is there an
    alternative that works? If there's an alternative, can you post
    example code?
    Thanks,
    Shannon

    I think you want window.location.href = "page2.html"
    When testing your code in a browser to see if it works, use
    WebKit or, if you're on a Mac,
    Safari. These use the same engine as AIR. Testing on IE only tells
    you that it's bug-compatible with IE, which isn't very helpful. You
    can also try Google Chrome, which uses the same HTML rendering
    engine as AIR, but not the same JS interpreter, so there can still
    be differences in behavior.
    I don't want to oversell this technique. AIR does have known
    differences with respect to the WebKit engine as used in standalone
    browsers, usually for security reasons. Still, if you find your
    code doesn't work in AIR, does work in IE or Firefox, but fails in
    WebKit or Safari, you know it's your code that's broken, not some
    limitation in AIR.

  • What HTML and JavaScript engine is used within Adobe AIR on the desktop?

    HTML and JavaScript within Adobe AIR are handled by the WebKit HTML/JavaScript engine.

    I've made a little headway with this. Within your initHandler just make a call to login:
    FacebookMobile.login(loginCallback, this.stage, [], webview);
    webview is a StageWebView instance with the viewPort defined. If I left it null, or didn't set the viewPort nothing happens...
    var webview:StageWebView = new StageWebView();
    webview.viewPort = new Rectangle(0,0,400,400);
    I'm now getting a login screen.

  • Will Adobe AIR apps work on iOS (Javascript/HTML)?

    Hello,
    I haven't been able to find any definitive answer on whether Adobe AIR apps using Javascript and HTML can work on iOS.
    Anyone know for sure?
    And if so, what happens with the APIs available through these swfs that we currently include:
    networkInfoWrapper.swf
    servicemonitor.swf
    applicationupdater_ui.swf
    Many thanks
    Stephen

    The answer is no. Apps developed for AIR using HTML and JavaScript are not supported on iOS or other mobile platforms. The mobile platforms do include a StageWebView component that can be used to load and display HTML and JavaScript. However, it is entirely different than the HTMLLoader control used on the desktop platforms (for HTML-based AIR apps). You cannot, for example, call any AIR/Flash APIs from JavaScript running in a StageWebView. In general, very little communication is possible between your ActionScript application code and the JavaScript code running in the StageWebView object.

  • Link in Adobe AIR JavaScript app is incorrectly opening the app in the default browser

    I have a couple of links in my Adobe AIR JavaScript app that are part of the app's UI, which when clicked are causing the app to be loaded into a new tab in my default browser.
    This is only happening with two links (Save and Cancel on a form), and not all links in my UI.  The two links that are having the issue are defined in an external HTML file that I load a runtime and connect to the DOM.  The links that are defined in the main HTML file that is loaded when the app starts up do not have this problem.
    Here is how I am loading the template and plugging it into the DOM
    var win = document.createElement("div");
    var f = air.File.applicationDirectory.resolvePath("lib/partials/edit_form.html");
    var fs = new air.FileStream();
    fs.open(f, air.FileMode.READ);
    var content = fs.readUTFBytes(fs.bytesAvailable);
    fs.close();
    var template = new Template(content);
    win.innerHTML = template.evaluate(data);
    document.body.insertBefore(win, document.body.firstChild);
    The links themselves are coded like this:
    <a href="#" id="save_button" onclick="return false;"></a>
    <a href="#" id="cancel_button" onclick="return false;"></a>
    I am using the Prototype JS library to observe the 'click' event for each of these links like so:
    $('save_button').observe('click', onSave);
    $('save_button').observe('click', onCancel);
    This app shows content created by users, which can contain links to external web sites.  To get the external links to open in the browser (as opposed to inside my Adobe AIR window), I am doing the following in a script tag in the head of my main HTML file:
    window.htmlLoader.navigateInSystemBrowser = true
    I've found that if I set window.htmlLoader.navigateInSystemBrowser = false, then the issue with the Save and Cancel links described above goes away.  However, I need to have window.htmlLoader.navigateInSystemBrowser = true so that external links in the user content open up in the browser, not in Adobe AIR.
    Another piece of evidence is that the Save and Cancel links only incorrectly open a browser the first time you click on them after launching the app.  Subsequent clicks work fine and do not have the issue.
    Any ideas on why the links that are plugged into the DOM after app start up have this issue, and only the first time you click on them?

    Not sure where this comes from, but I suspect it has something to do with the security restrictions that AIR has in place, related to dynamic JS evaluation after the document is loaded.
    Make sure you read http://help.adobe.com/en_US/air/html/dev/WS5b3ccc516d4fbf351e63e3d118666ade46-7f0e.html#WS 5b3ccc516d4fbf351e63e3d118666ade46-7ef8
    For example, I've spotted the two onclick="return false;" you have in your code. The evaluation of the onclick attribute after the page loaded event would fail in AIR.

  • Adobe AIR (JavaScript/AJAX) is dead?

    Hi all,
    I used to code in AIR for JavaScript / Ajax in v1 and v1.5 of AIR. I am trying to refresh my coding skills into this platform but there seems to be very poor knowledge base and material at the web, I am wondering whether this platform is somehow deprecated and whether only Adobe AIR (Flex) is supported.
    Can you please clarify?
    thank you,
    George

    Bump! I'd like to know, too. We have a large html/javascript app and are wanting to use it on Android or iOS, but it kinda seems like everything is Flex based now.... ???
    - Jack

  • Adobe AIR for HTML/JS custom Javascript Scrollbars

    Hi,
    I would like to know if it is possible to have custom Javascript scrollbars in an Adobe AIR application.
    I have tried many jQuery plugins but nothing can style the scrollbars.
    I can only style them via CSS.
    Adobe AIR supports javascript scrollbars for HTML / iFrames?

    Filed feature request on bugbase. Vote it up if you agree!

  • Adobe Air - HTML, Javascript and Threading

    Hello,
    I am developing an application using Adobe Air - HTML and
    Javascript. What I am trying to do is to implement threading in
    Javascript. I am using implementing threading in Javascript as per
    this Neil blog.
    Click
    Here. It clearly says that this threading works only in Firefox
    2.0 and I am trying to use this in with my Adobe Air, but when I
    try to refer a function , it gives me error saying "unable to find
    it".
    I was wondering if this is the best way to go for threading
    in Adobe Air HTML application or there is some other way also.
    Thanks,
    Jaikishan

    Hi jjalan,
    The yield and generator functionality is only available in
    Firefox's javascript execution engine. When you are executing
    javascript in AIR, it is done by the webkit and squirrelfish. Take
    a look at
    http://webkit.org/blog/189/announcing-squirrelfish/
    If you can find a javascript library that works on safari /
    webkit, chances are high that it may work in AIR.
    Also, you can always do pseudo-threading via the age old
    setTimeout()

  • Javascript ajax loaded in adobe air

    Hello to all,
    I come on this forum because i meet a problem with AJAX and JAVASCRIPT.
    In my main script of ADOBE air, i load with "Ajax" the javascript contents but this javascript not execute not.
    All my functions are in the < head > only the calls are in the contents
    in charge of contents loaded with and the functions are called by onclick.
    That here is my  script for the forum, but is characteristic of my problem:
    <head>
    <script type="text/javascript">
    function getRequeteHttp() {
    ////the contents was supprimed for the example////
    function sendRequete(url) {
    ////the contents was supprimed for the example////
    function receiveReponse(requeteHttp) {
    if (requeteHttp.readyState==4) {
    (requeteHttp.status==200) {
    visibleReponse(requeteHttp.responseText);
    else {
    alert("error");
    function visibleReponse(rep) {
    document.getElementById("back2").innerHTML=rep;
    function action() {
    sendRequete('tryscript.html');
    function yiu(){
    alert('rooooooo');
    </script>
    </head>
    <body style="margin:0px;padding:0px;font-family:'Trebuchet MS';background:gray;" >
    <div>
    <input type="button" value="click" onclick="action();" />
    <div id="back2">
    <!--Contents loaded with ajax-->
    <input type="button" value="click2" onclick="yiu();" />
    <!---->
    </div>
    </div>
    </body>
    </html>
    Thank you for your assistants and forgiveness for my English

    Thank you for your answer,
    I'll go to read content's  links, once this made, i'll come back to explain my new situation.
    Cordially, thank you one more time.

  • Adobe Air (Javascript) Barrierefreiheit

    Kann mir jemand sagen wie weit Adobe Air Applicationen Barrierefrei entwickelnt werden können.
    Die visuellen vorraussetzungen wie Kontrast und Schriftgröße sind ja zu realisieren.
    Aber wie sieht es mit der Funktionalität mit Screenreadern und anderen Vorraussetzungen aus?
    Mit der Verwendung von Flex gibt es ja einige Informationen nur leider habe ich nichtz zu JavaScript gefunden, oder kann ich eine Adobe Air Application wie einen Browser ansehen?

    Also, ich kann momentan nix mit einem Screenreader ausprobieren, weil meine Soundkarte kaputt ist ;-)
    Am besten mal den Thunder Screenreader installieren und probieren, ob der mit einer HTML/Javascript - basierten AIR-Anwendung zurecht kommt.

  • How can I run a .bat file from an html/javascript adobe air installation package?

    I write an html/javascript code which works completely true
    but when I made the installation package by air-sdk
    it dosent work properly
    my code is:
    <html>
    <head>
        <title>Hello World</title>
              <script type="text/javascript">
            function appLoad() {
                air.trace("Hello World");
        </script>
    </head>
    <body onLoad="appLoad()">
        <h1>Hello World</h1>
              <br />
    <button onclick="window.open('file:///C:/Windows/notepad.exe')"> Launch notepad </button>
    <button onclick="window.open('file:///D:/opennotepad.bat')"> Launch batnote </button>
    </body>
    </html>
    Chapter 5: Creating your first HTML-based AIR application with the AIR SDK

    Seems to be security violation. You can't execute bat or cmd

  • Books on Adobe Air development using HTML/JavaScript

    Hi,
    I always been of the opinion that one of the signs of a healthy, viable technology is the availability of books and manuals (not just articles or short tutorials online) on how to use said technology. I'm interested in Adobe AIR development for Dekstops/Tablets but I have not been able to find any new books on the topic. Most of the existing books seems to date from 2008 and are targeted towards AIR 1.0-1.5, while the latest version of Adobe Air apparently is 3.5+. So my question is - Where are all the books?
    /Sincere Regards Kris

    quote:
    Originally posted by:
    pravinpatil23
    But can you please explain me when do I exactly use Flex Or
    HTML+JS Or Flash.
    This question gets asked about once a week. You
    can find my latest answer
    here
    and a little searching will dig up more opinions.
    quote:
    Can AIR applications(developed using HTML+Js) invoke a web
    service running on a different server
    An AIR application isn't hosted on a server, so all web
    servers are "foreign" to your AIR application. An AIR app does get
    downloaded from a server, most of the time, but it doesn't maintain
    some kind of special connection to that server.
    Because of this, there are no cross-domain restrictions in
    AIR like you have in a regular web browser.
    quote:
    Can AIR application(developed using HTML+Js) detect the
    connectivity of USB drive
    AIR does not allow low-level system access, and has very
    little in the way of platform-specific capabilities. So, you'd have
    to use a high-level, platform-agnostic way of checking for the
    drive, such as by looking around to see what files are available.
    Things like USB insert notifications are way outside the scope of
    AIR.
    quote:
    I want the data from Servlet to send back to HTML page where
    I can display it on the same HTML page where user entered his
    details.
    That question isn't on-topic here. Ask on a forum dealing
    with JSP servlets.

  • Printing in Adobe AIR (JavaScript / Ajax) whereas skipping the print dialogue

    Hi,
    Can I do what the topic says? Basically I would like to check with a timer a URL and once something appears there I want it to be sent directly to my default printer.
    Is that possible? And if Yes, how?
    thank you,
    George

    Hi, I have not investigated exactly your problem as yet but this seems to be related to it:
    http://anirudhs.chaosnet.org/blog/2008.02.15.html
    For me it was printing only the upper-left corner
    but specifing a Rectangle for size for PrintJob.addPage() second argument fixed that
    please consult
    http://www.adobe.com/livedocs/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context =LiveDocs_Parts&file=00000334.html
    for help on Rectangle. You can use geom instead of display;
    frameworks/libs/air/AIRAliases.js contains an alias directly to geom:
    air.Rectangle = window.runtime.flash.geom.Rectangle;
    so you may use directly air.Rectangle to construct the size.
    It works on AIR 1.5 as well as AIR 2 beta
    Code snippet I have used and worked:
    function doPrintAir()
        var pjob = new window.runtime.flash.printing.PrintJob;
        if ( pjob.start() )
            var poptions = new window.runtime.flash.printing.PrintJobOptions;
            var rectangle = new air.Rectangle(0, 0, 800, 800);
            poptions.printAsBitmap = true;
            /* poptions.pixelsPerInch = 300; */
            try
                pjob.addPage(window.htmlLoader, rectangle, poptions);
                pjob.send();
            catch (err)
                alert("exception: " + err);
        else
            alert("PrintJob couldn't start");
    //comment the line below if you do not want to mess with existing
    //window.print
    window.print = doPrintAir;
    this make js window.print() available for use as one would normay do.
    Let me know if this helps and fixes your problem.
    Best regards,
    Daniel Baragan - Adobe AIR Engineer

  • Ctrl-v key combo not working in keydown event in Adobe Air

    I am needing to capture the ctrl-c/ctrl-x/ctrl-v keys in the keydown Javascript event from within Adobe Air.
    I have managed to get the events to fire correctly.
    When I press ctrl, c, x, v, ctrl-c and ctrl-x, I get the correct corresponding keycodes. However, when I press ctrl-v, no event gets triggered.
    Is Air preventing the key presses from reaching this event in the case of ctrl-v?
    Here is the code I am using:
        document.getElementById('main_grid').addEventListener('keydown', keyDownEvent, false);
        keyDownEvent = function(e) {
            alert(e.keyCode);

    I'm surprised you get ctrl-c and ctrl-x. Do they work when you have selected text? What is probably happening is the default handler for the paste event is "swallowing" the keystroke. You could try listening for the paste event and calling the event object's preventDefault() method. (I haven't tried it, though, so I'm not positive that would allow the keystroke to be passed along.) If you are trying to create your own copy/paste functions, you might be better off listening for the copy and paste events themselves, rather than the raw keystrokes.
    Another alternative is to listen for the keystrokes on window.htmlLoader, which should get the keystrokes before they are passed to the HTML engine.

  • Problem in making installation package by adobe air sdk

    I made an installation file with adobe air (a javascript/html  code by installing  AIRSDK) ,
    after makeing the file when I want to run it , it send an error message "This application cannot be installed because this installer has been mis-configured. Please contact the application author for assistance."
    http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7ecc. html
    Chapter 5: Creating your first HTML-based AIR application with the AIR SDK

    try to update your air runtime. This is popular issue when developers use newer sdk but old runtime. Or include runtime to your app

Maybe you are looking for