Skip navigation
roelofroos
Currently Being Moderated

Getting the document object cross-window

Aug 7, 2010 9:31 AM

Hello,

 

I've been working on this application in which I have 2 windows.

 

Now the main window needs to make a call to the sub window sending a single function.

 

I have the following code to create the window:

 

var options = new air.NativeWindowInitOptions();
options.systemChrome = "none";
options.type = "lightweight";
options.resizable = true;
options.maximizable = true;
var winwid = 600;
var winhei = 500;
var mainWidowPos = new Array();
var mainWindowPos = getTopLeft(winwid,winhei); //This function is to calculate the center of the screen
var windowBounds = new air.Rectangle(mainWindowPos[0],mainWindowPos[1],winwid,winhei);
newHTMLLoader = air.HTMLLoader.createRootWindow(true, options, true, windowBounds); 
newHTMLLoader.load(new air.URLRequest(url));

 

 

Now that that window is created I need to make a call from window 1 to window 2 (the newly created one, the title of the window is SCR2_BILL).

 

Maybe this table can clear it up:

 

 

Window 1 (main)Window 2 (created by code)

This code is in window 1 and is being called:

 

for (var i = 0; i < air.NativeApplication.nativeApplication.openedWindows.length; i++) {
     if(air.NativeApplication.nativeApplication.openedWindows[i].title == "SCR2_BILL") {
          air.NativeApplication.nativeApplication.openedWindows[i].window.htmlLoader.stage.nativeWindow.hideBill();
     }
}
function hideBill() {
     document.getElementById('bill').style.display = 'none';
}

 

The link does not exist because air.NativeApplication.nativeApplication.openedWindows[i].window.htmlLo ader.stage.nativeWindow is not an object. Does anyone know what the object is after openedWindows[i] which I can use to call functions from the document?

 

Thanks in advance,

 

Roelof

 

PS: the code window 2 is executing is working, it has been tested.

 

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points