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();
var content = fs.readUTFBytes(fs.bytesAvailable);
var template = new Template(content);
win.innerHTML = template.evaluate(data);
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:
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.
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.