Air - JavaScript DOM problems

Dear Air-friends,
Have a look at this short html:
<html>
<head>
<script type="text/javascript"
src="AIRAliases.js"></script>
<script>
var i = 0;
var click = function() {
var a = document.createElement("a");
a.innerHTML = "click me " + i++;
a.setAttribute("href", "#");
a.setAttribute("onclick", "click()");
document.getElementById("body").replaceChild(a,
document.getElementsByTagName("a")[0]);
</script>
</head>
<body id="body" onload="click()">
<a />
</body>
</html>
when I run this using adl something strange happens:
- I get a "click 0", after I click a "click 1" and ....
that's it! no continuous "click 2", etc.
I isolated this problem to this example, but actally I need
it for context menus in my air application.
Can someone help? I'm out of ideas.
Thanks,
Harrold Korte

Hi Joe,
First of all, thanks for your quick reply!
Maybe I isolated the problem a bit too much. In fact, I'm
creating context menus using xslt.
Each time, a new context menu is put under a node called
<div id="wrap-menu"> containing
a <ul> of <a>s. It is in these subsequent
refreshing of the context-menu (produced by xslt)
where I observed this behaviour (first time ok, second time
nop). Should I alter each <a> in the produced context-menu
with addEventListener afterwards?
I have the feeling that in that case I could didge xslt as
well. Unfortunatly, I'm a big xslt fan to create
html output (instead of all these program lines of unpacking
and DOM manipulation). I'm porting an
application from JS/PHP to Air because of the file system
access which is exactly what I was looking for.
Thanks again,
Harrold Korte

Similar Messages

  • 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.

  • Javascript security problem in IE/Netscape

    I am facing with the javascript security problem in IE/Netscape. I have solved this problem partially, but there are more issues involved.
    Here's the scenario:
    There is an HTML page on client's hard disk (main.htm) containing two frames:
    frame 1 contains a page that lies that is deployed from my server, say
    src="http://127.0.0.1:8080/MyApplication.htm"
    frame 2 contains a page that lies on the client's server, say
    src="http://www.clientside.com/clientPage.htm"
    My page in frame 1 wants to access the URL of the page in frame 2 (through a button click, say ). This is done in MyApplication.htm through javascript as:
    window.parent.frame2.location.href;
    Now when the above line is executed, i get the following error:
    In IE(5.0): "permission denied"
    In Netscape(4.7): "access disallowed from scripts at http://127.0.0.1:8080/MyApplication.htm to documents at another domain."
    (which is understandable)
    I have partially solved the above problem in Netscape, by granting access permissions to MyApplication.htm (page on my server) to access the
    "http://www.clientside.com/clientPage.htm" page at client's domain.
    This is done as follows:
    1. First enable code base principals in client's Netscape by adding the following line in prefs.js file of Netscape
    "user_pref("signed.applets.codebase_principal_support", true);"
    2. Secondly i must add the following line in java script of "MyApplication.htm"
    "netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserAccess");"
    Now when the client clicks the button on my frame he'll get a netscape window asking him to grant permissions to MyApplication.htm.
    After granting permission, MyApplication.htm can retrieve the URL of clientPage.htm (even if he browses to another url)
    As you can see this problem is solved partially, but i want that the page "main.htm" (which is now on the client's hard disk),
    must be deployed at client's server (in which case not even the above technique works).........what should i do? any alternates or other solution?
    Secondly i want this to work with IE too, (which should according to their documentation, but does not and is therfore a big IE bug-as mentioned on the net)
    Any sort of help in this case would greatly appreciated.
    Thanks
    Faisal Moin Khan

    i believe you are posting in the wrong forum.
    This forum is foro XML web services.

  • I have the Numbers-applications on both Mac mini and Macbook Air. My problem is that they don't sync so when I create a Numbers-file on the MacBook  while travelling, it will not be on my Mac mini when I get home :(((

    I have the Numbers-applications on both Mac mini and Macbook Air. My problem is that they don't sync so when I create a Numbers-file on the MacBook  while travelling, it will not be on my Mac mini when I get home :(((

    Hey iWeb plubishing problems,
    I would first check to make sure that you meet the system requirements for OS X to support Documents in the Cloud. For that your Mac’s needs to be running at least OS X Lion 10.7.5 or later to make sure that everything syncs. Take a look at the article below for more information. 
    iCloud: Troubleshooting Documents in the Cloud
    http://support.apple.com/en-us/HT203517
    Take care,
    -Norm G. 

  • Air and sqlite problem - cumulating results

    Hi,
    I got problem with sqlite in air.
    The problem is that sqlStmt.getResult().data is gathering data from separate Select statements, when  it should be separate results. As in this example, where I call "select" function once, and AFTER geting it's result I call it again with different query.
    public function select(q:String):void {
    conn.open(dbFile);
    sqlStmt.addEventListener(SQLEvent.RESULT,selectComplete);
    sqlStmt.text = q;
    sqlStmt.execute();
    private function selectComplete(e:SQLEvent):void {
    oSqlReturn = sqlStmt.getResult().data;          //this is where sqlStmt.getResult().data remembers previous results and adds current ones to the array.
    conn.close();                                                  //but here sqlStmt.getResult() is null
    sqlStmt.removeEventListener(SQLEvent.RESULT,selectComplete);
    So  after second Select returns I got sqlStmt.getResult().data with results from the first and the second statement.
    Maybe one of You had some simmilar problem and is able to help me with this.

    Thanks for help. It is recomended to use different instances of SQLStatement. But it wasn't the case.
    I changed to asynchronious connection and I added SQLMode and now it works.
    So instead of
    conn.open(dbFile)
    now I got this:
    conn.openAsync(dbFile,SQLMode.UPDATE);
    So I think that the problem was becouse I was listening to result events of synchronious connection.

  • Macbook air Shut down problem

    Hi everyone,
    I used to have the shut down problem with my Macbook air. I have an 11" Later 2011 Macbook air.
    The problem did not go away after updating to Mountain lion.
    I just realized that although I was closing all programs, I was not ejecting my 3G modem/dongle.
    Once I ejected it before commanding it to shut down, it did shut down properly.
    I thought I should share it with you. May be there is a program that has not been closed or a devise that has not been unplugged/ejected properly and is restricting the shut down.
    It worked for me. Hope it will work for you.
    Enjoy your Mac.
    J.

        Reset SMC.     http://support.apple.com/kb/HT3964
        Choose the method for:
        "Resetting SMC on portables with a battery you should not remove on your own".
         If this does not help, you may have to take the computer to the Apple store
         to have the battery checked out.
         Best,

  • Applet - JavaScript communication problem

    Hi,
    I am creating applet parameter using JavaScript (DOM Tree). But when i am accessing inside the applet, it is coming as null.
    Here is code:
    JavaScript Code:
    <html>
    <head>
    </head>
    <script language="JavaScript">
         function testXML(){
              var applet = document.getElementById("graftApplet");
              var param = document.createElement("param");
              param.setAttribute("name","graft4");
              param.setAttribute("value","25:10|20:50|172:220");
              applet.appendChild(param);          
    </script>
    <body onload=testXML()>
    Applet embedded here!
    <br>
    <hr>
    <APPLET id="graftApplet" CODE=Graft.class width=400 height=500 mayscript>
    </APPLET>
    <br>
    </body>
    </html>Applet code:
    public void init()
    System.out.println(getParameter("graft4")); //it is prinitng NULLcan you please tell me where i am wrong?
    Thanks
    Chintan

    Did u Try this
    <APPLET id="graftApplet" CODE=Graft.class width=400 height=500 mayscript>
    <PARAM NAME="name" VALUE="25:10|20:50|172:220">
    </APPLET>

  • Systray icon in AIR strange bitmap problem

    Hi there i recently tried to have one of my apps docked to systray instead of taskbar so i've used pretty much the examples floating around and everything went smoothly except the icon itself. I used standard 16x16 png file and it got scrambled looks like each 4th line is shown or something like that. So i've tried with JPG and ended with pure code generated bitmap data but always with the same result. Here is a screenshot of my systray when using new BitmapData(16,16,false,0xFF0000) and assigning it to the bitmaps array of the icon.
    To the left is my AIR application icon which should be 16x16 sized red square however once again glitched. To the right is the classic gtalk icon.
    Everything else except the graphics itself works perfectly.
    Any ideas of whats going on? Or is this some kind of bug in the latest AIR? By the way i am using AIR 2.5
    Thank you.

    Ok did further testing and it seems to be AIR 2.5 problem only. In previous AIR the bitmap is displayed correctly, so i've filed a bug report to Adobe.

  • Will AIR has any problems in the future with Android?

    Will AIR has any problems in the future with Android?
    If we are experienced in flash, is it better to do the mobile work with AIR or HTML5?
    But we are doing flash only so that we may face problems if we faced any bugs, is it expected to have any bugs or complexities, we can do flash with AS3 and we will depend on flash in publishing

    Do you mean you dropped the iPad Air?  Is it working properly?  Is the screen damaged?
    If it is working properly and has no signs of damage, it is probably ok.

  • Is there any AIR/javascript framework ?

    hi every body is there any AIR/javascript framework ?????
    thank you in advance

    You can use every JavaScript framework working in combination with jQuery.
    However, what exactly do you mean when saying "supported by SAPUI5"? Do you mean additional controls or UI libraries?
    Regards
    Tobias

  • First time I planned to buy a ipad Air. After seeing ipad Air having screen problems, dropped my plan. Planning to go for samsung Note 10.1 2014 edition.

    First time in my life, I planned to buy a ipad Air. After seeing ipad Air having screen problems in the community, dropped my plan. Shall I go for for samsung Note 10.1 2014 edition otherwise wait for ipad Air 2.

    For every iPad Air with screen problems there's a million that work fine.. If you buy at the Apple Store take a good long look and hand it back if it's not right.

  • I currently have an iphone that i connect to my mac air to download music, i have now bought a nano for my wife can we use both devices on the same air without any problems???

    i currently have an iphone that i connect to my mac air to download music, i have now bought a nano for my wife can we use both devices on the same air without any problems???

    My wife and I both have the iPhone 4 and it's actually pretty simple. Add another user on your MBA (her) and she can use the other iTunes when she is logged in. The iTunes is empty and will erase her iPhone, so be sure that she syncs her iPhone, then back up her library onto a portable media device like I did (SD Card) and reload it onto her empty iTunes on your MBA before she attempts to sync with it.
    Works well...
    Sly

  • Adobe Air package damaged -problem

    Hi!
    I packaged my Adobe Air HTML/JavaScript -application with Dreamweaver CS 5.5 AIr Extension. Packaging with homemade signature went without any problems, but installing the application doesn't work. I get the error #1000 during installation. I suspect that problem relates to same bug that has been discussed in this thread: http://forums.adobe.com/thread/778613#3405543 (internal bug number 1674848). I thought that the bug has been resolved, but the installation works if I remove large (420MB) sqllite-db-file from package. The package's compressed size is ~ 95MB.
    My developing enviroment:
    Windows 7 x64 (4GB RAM)
    Adobe Dreamweaver CS5.5
    Latest Adobe Air Extension for Dreamweaver
    Latest Adobe Air runtime  / SDK (2.7; I have also tried building from command line with same results)
    Is the bug still there or should I try something else?

    The only idea that comes to mind is to keep the file on the dvd, then have your app install (copy) it on first launch.
    Thanks for adding the bug.  For others affected by this, please visit the bug and add your vote.  All feedback is appreciated!
    https://bugbase.adobe.com/index.cfm?event=bug&id=2938315
    Chris

  • Air badge installApplication() problems

    The installer for the application of air stopped working for the user who has not installed the air.
    I tested this in my installer (http://www.artclick.vn/article/download-install-acbook-offline-version-software-design-pho tobook-41.html) and other as the lita (Lita - SQLite Administration Tool | David Deraedt)

    Hi Joe,
    First of all, thanks for your quick reply!
    Maybe I isolated the problem a bit too much. In fact, I'm
    creating context menus using xslt.
    Each time, a new context menu is put under a node called
    <div id="wrap-menu"> containing
    a <ul> of <a>s. It is in these subsequent
    refreshing of the context-menu (produced by xslt)
    where I observed this behaviour (first time ok, second time
    nop). Should I alter each <a> in the produced context-menu
    with addEventListener afterwards?
    I have the feeling that in that case I could didge xslt as
    well. Unfortunatly, I'm a big xslt fan to create
    html output (instead of all these program lines of unpacking
    and DOM manipulation). I'm porting an
    application from JS/PHP to Air because of the file system
    access which is exactly what I was looking for.
    Thanks again,
    Harrold Korte

  • Mid-2013 macbook air Battery life problem

    hi,
    i don't know what's the problem on my macbook air but battery life always shows less than 10 hour...
    any idea?
    i have posted that etrecheck results...  what should i do?
    Hardware Information:
              MacBook Air (13-inch, Mid 2013)
              MacBook Air - model: MacBookAir6,2
              1 1.3 GHz Intel Core i5 CPU: 2 cores
              4 GB RAM
    Video Information:
              Intel HD Graphics 5000 - VRAM: 1024 MB
    Audio Plug-ins:
              BluetoothAudioPlugIn: Version: 1.0
              AirPlay: Version: 1.9
              AppleAVBAudio: Version: 2.0.0
              iSightAudio: Version: 7.7.3
    System Software:
              OS X 10.9 (13A603) - Uptime: 0 days 0:8:22
    Disk Information:
              APPLE SSD SM0256F disk0 : (251 GB)
                        EFI (disk0s1) <not mounted>: 209.7 MB
                        Macintosh HD (disk0s2) /: 250.14 GB (13.29 GB free)
                        Recovery HD (disk0s3) <not mounted>: 650 MB
    USB Information:
              Apple Internal Memory Card Reader
              Apple Inc. BRCM20702 Hub
                        Apple Inc. Bluetooth USB Host Controller
    FireWire Information:
    Thunderbolt Information:
              Apple Inc. thunderbolt_bus
    Kernel Extensions:
    Problem System Launch Daemons:
    Problem System Launch Agents:
    Launch Daemons:
              [loaded] com.adobe.fpsaud.plist
              [loaded] com.adobe.SwitchBoard.plist
              [loaded] com.google.keystone.daemon.plist
    Launch Agents:
              [not loaded] com.adobe.AAM.Updater-1.0.plist
              [loaded] com.google.keystone.agent.plist
    User Launch Agents:
              [failed] com.coppertino.VoxHelper.plist
              [failed] com.google.GoogleContactSyncAgent.plist
              [loaded] com.spotify.webhelper.plist
    User Login Items:
              iTunesHelper
              Adobe Bridge CS5
    3rd Party Preference Panes:
              Flash Player
    Internet Plug-ins:
              AdobePDFViewer.plugin
              Default Browser.plugin
              Flash Player.plugin
              FlashPlayer-10.6.plugin
              Flip4Mac WMV Plugin.plugin
              googletalkbrowserplugin.plugin
              JavaAppletPlugin.plugin
              npgtpo3dautoplugin.plugin
              o1dbrowserplugin.plugin
              QuickTime Plugin.plugin
    User Internet Plug-ins:
    Bad Fonts:
              None
    Time Machine:
              Time Machine not configured!
    Top Processes by CPU:
                   5%          WindowServer
                   3%          Dock
                   1%          EtreCheck
                   1%          fontd
                   0%          warmd
                   0%          loginwindow
                   0%          aosnotifyd
    Top Processes by Memory:
              123 MB             com.apple.IconServicesAgent
              82 MB              Finder
              78 MB              CVMCompiler
              70 MB              Safari
              61 MB              mds_stores
              57 MB              WindowServer
              57 MB              Mail
              57 MB              com.apple.WebKit.WebContent
              53 MB              Dock
              29 MB              mds
    Virtual Memory Statistics:
              1.36 GB            Free RAM
              1.31 GB            Active RAM
              796 MB             Inactive RAM
              561 MB             Wired RAM
              351 MB             Page-ins
              0 B                Page-outs

    battery time remaining is currently unreliable, techs are looking into it.
    What ACTUAL time are you getting off a full charge?
    rely on battery % until there is a resolution
    there are no suspect apps or processes in your list that i see
    Peace

Maybe you are looking for

  • New Alum Macbook 2.4 not connecting to TV

    Like many others here, I've been unsuccessful connecting my new MacBook to my Samsung LCD with the new MD to VGA. Since it's not working, I'd like to return it and hopefully purchase another adapter (maybe HDMI?) if there's an alternative other folks

  • State Change causing tree item to loss selected item highlight

    I'm looking for some guidance on a situation i'm encountering. I've an application with a tree component which will be used as a report selector in all view states. The parent nodes are not selectable but the children are. Each child has a for a lack

  • DW MX & Contribute

    Just wondering whether anyone can comment on this ftp log from trying to get my copy of DW MX to administer / set up Contribute fucntionality on a site (server passes tests with the adobe downloadable ftp testing tool) server ftp software is pure_FTP

  • JSX Save PNG for web, quality parameter not changing file size

    Hi I have a script that uses this snippet of code to save png files for web. But, no matter what number I change the quality, the resulting file size and image fidelity remains the same. I was wondering if I can save pngs for web at smaller byte size

  • Unable to remove CSS 6

    I am trying to upgrade from CSS6 and RNR 3.0 to CSS 8.2.  The instructions direct me to remove CSS6 and RNR3 and then install CSS8.2 I removed RNR3 after a bit of difficulty, but cannot remove CSS6 as it does not appear in the 'Add/Remove Programs' i