Inter-window communication

13 views
Skip to first unread message

Dennis Próchniak

unread,
Sep 19, 2013, 1:08:03 PM9/19/13
to node-...@googlegroups.com
How can I eval code in a new window and run a callback in the eval window which will call a method in the primary window?

  var gui, win;
  gui = require('nw.gui');
  win = gui.Window.get();
  n = gui.Window.get(window.open('file:///foohax.html'));

  n.eval('doSomething(function(){ /* call a method from the primary window */})

How inter-window communication should be done in general?

--
-----------------------------------------------
Dennis Próchniak

LZAntal

unread,
Sep 19, 2013, 3:18:46 PM9/19/13
to node-...@googlegroups.com
Hi,

On Sep 19, 2013, at 10:08 AM, Dennis Próchniak <denni...@gmail.com> wrote:

How can I eval code in a new window and run a callback in the eval window which will call a method in the primary window?

  var gui, win;
  gui = require('nw.gui');
  win = gui.Window.get();
  n = gui.Window.get(window.open('file:///foohax.html'));

  n.eval('doSomething(function(){ /* call a method from the primary window */})

How inter-window communication should be done in general?


If both window using the same domain you can use frameset and use frames to load different "pages" into them. Then you can use parent.postMessage() to communicate. I haven't tried it with node-webkit but I don't see why it wouldn't work.
--
-----------------------------------------------
Dennis Próchniak

--
You received this message because you are subscribed to the Google Groups "node-webkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-webkit...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages