Well, this may not be the correct answer to the question "How to call a function in another window," but the answer to your initial problem is "How to send parameters to a new window" (before editing the name).
HTML5, sessionStorage ( , ).
:
index.html( )
<!DOCTYPE html>
<html>
<body>
Test <a href="">Click</a>
<script src="jquery-1.11.1.min.js"></script>
<script>
var mySharedObj = {
'one': 1,
'two': 2,
'three': 3
};
var gui = require('nw.gui');
$('a').click(function() {
var win = gui.Window.get(window.open('index2.html'));
win.eval(null, 'sessionStorage.setItem(\'mySharedJSON\', \''+JSON.stringify(mySharedObj)+'\');');
});
</script>
</body>
index2.html( , window.open:
<!DOCTYPE html>
<html>
<body>
Test 2:
<script src="jquery-1.11.1.min.js"></script>
<script>
$(document).ready(function() {
var mySharedObj = JSON.parse(sessionStorage.getItem('mySharedJSON'));
console.log(mySharedObj);
});
</script>
</body>
, ? window.eval (. ) , . , , script , DOM , JavaScript . , ( window). , , JSON window.sessionStorage. , .
: , .