Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Accessing the DOM and functions of other windows.

I need some sort of communication between two windows. What is the syntax for accessing the DOM of another window, or preferably calling a function in another window?

— asked September 30th 2010 by Caleb Solano
  • communication
  • desktop
  • dom
  • syntax
  • window
0 Comments

2 Answers

  • I have figured it out.

    Titanium.UI.getWindows()[1].getDOMWindow().window2Function(param,param);

    — answered September 30th 2010 by Caleb Solano
    permalink
    0 Comments
  • I don't know about accessing the DOM, but if you just want to call a function in another window, you can do this by events. Simply fire an event in one window, the window you want the function called in can listen and the event listener can then call the function. Events were talked about in this blog entry.

    — answered September 30th 2010 by Mike Robinson
    permalink
    4 Comments
    • So what does Titanium.UI.UserWindow.getDOMWindow actually return?

      — commented September 30th 2010 by Caleb Solano
    • Firing and Listening for events seems to work to a certain degree. But I need a solution that will allow me to pass variables. Ideally, Titanium.UI.getWindows()[1].window2Function(param,param);

      — commented September 30th 2010 by Caleb Solano
    • Glad you figured it out……but so you know you can put arguments in the event object, and then use those when calling the function.

      — commented September 30th 2010 by Mike Robinson
    • You can fire an event but you cant pass data to the listener function in the Desktop API. Passing an object to the listener is only possible in the Mobile API as of Desktop ~ Titanium.API.fireEvent v0.5.0

      — commented December 12th 2011 by Gaurav DCosta
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.