I am currently creating an HTML / JS AIR application. The application should display another “window” to the user - depending on whether this is the first time the application is launched or not. This part is actually beautiful, and for this I need the following code:
if(!startUp()) {
var windowOptions = new air.NativeWindowInitOptions();
windowOptions.systemChrome = 'none';
windowOptions.type = 'lightweight';
windowOptions.transparent = 'true';
windowOptions.resizable = 'false';
var windowBounds = new air.Rectangle(300, 300, 596, 490);
var newHtmlLoader = air.HTMLLoader.createRootWindow(true, windowOptions, true, windowBounds);
newHtmlLoader.load(new air.URLRequest('cover.html'));
}
else {
}
However, I want this to be done is to manipulate the contents of the html from cover.htmlafter loading it. There seems to be a lot of online tutorials on how to move, resize, etc. NativeWindowbut I just want to access the HTML content NativeWindow.
For example, how to add a new paragraph to this page? I tried the following:
newHtmlLoader.window.opener = window;
var doc = newHtmlLoader.window.opener.document.documentElement;
Using the AIR Introspector console, ... .log(doc)returns [object HTMLHtmlElement].
Hmm, seems promising? Then I will try:
var p = document.createElement('p');
var t = document.createTextNode('Insert Me');
p.appendChild(t);
doc.appendChild(p);
... . doc:
var doc = newHtmlLoader.window.opener.document.body; // .log(doc) -> [object HTMLBodyElement]
var doc = newHtmlLoader.window.opener.document; // .log(doc) -> Error: HIERARCHY_REQUEST_ERR: DOM Exception 3
... jQuery:
$(doc).append('<p>Insert Me</p>');
, - - NativeWindow? .