Adobe Integrated Runtime (AIR) for JavaScript Developers Pocket Reference

(nextflipdebug5) #1

66 | Chapter 4: AIR Mini-Cookbook


Windowing


Creating a New Window


Problem


You need to display an additional widow into which addi-
tional content can be loaded.


Solution


Basic windows can be generated and maintained in a similar
fashion as traditional HTML content using thewindow.open( )
method.


Discussion


The JavaScriptwindow.open( )method invokes a new win-
dow similar to the way it would when used in the browser.
Content that gets loaded into the new window can come
from a local file, or URL endpoint. Similar to windows cre-
ated using JavaScript in the browser, there is finite control
over the window itself. The window properties that can be
controlled are width, height, scrollbars, and resizable.


var login = window.open( "login.html", "login", "width =
300, height = 200" );

Anative window is a better choice when additional control
over the new window is required. Native windows expose vir-
tually the entire functionality of the operating system such as
minimize/maximize, always in front, full screen and even
removal of system chrome altogether. The drawback to using
native windows is that there is substantially more work
because all events must be monitored and managed explicitly.


TIP
Thewindow.openerproperty that is commonly used in
JavaScript to refer from a new window to the parent (cre-
ating) window can also be used.
Free download pdf