I have develop a simple nw.js (ex node-webkit) application. It open a fullscreen Iframe with attribute
nwfaketop
Inside this iframe ( logically in different domain) I need to call a parent nodejs function. How can I do? Here code of my index.html main nw.js app:
<html>
<body style="margin:0">
<iframe src="https://www.mydomain.it/test.html" style="width:100%;height:100%;border:0;padding:0" nwfaketop></iframe>
<script>
var gui = require('nw.gui');
var win = gui.Window.get();
win.showDevTools();
var clipboard = gui.Clipboard.get();
function copy_do(text){
clipboard.set(text, 'text');
}
onload = function() {
win.maximize();
}
</script>
</body>
</html>
And here code inside iframe on https://mydomain.it/test.html
<!doctype html>
<html lang="it">
<head>
<meta charset="UTF-8">
<title>Test page</title>
</head>
<body>
<div style="text-align: center;">Test page</div>
<script>
parent.copy_do("stackoverflow");
</script>
</body>
</html>
As you see I need to call function
copy_do();
from parent main file.
How can I do? Thanks in advance
window.parent.postMessage, I think it should also work in nw.js. blog.teamtreehouse.com/cross-domain-messaging-with-postmessage May be in your case you pass js code what you want to run in a message. - Pavel Evstigneev