【发布时间】:2014-08-29 13:56:14
【问题描述】:
我已经用这段代码创建了一个新窗口并尝试发送一些数据但没有调用该函数,也许我做错了?
index.html 上的 script.js
var path = require('path');
element.onclick = function(){
var win = gui.Window.get(window.open('listdir.html'));
var location = path.resolve(process.cwd(),'fontsFolder');
win.eval(null, 'listdir("'+location+'")'); //Is there a node function to parse '\'?
};
listdir.js 上的 listdir.html
function listdir(directory){
alert("directory "+directory); //never called
}
错误:
ReferenceError: listdir is not defined
at <anonymous>:1:1
at Window.init.Window.eval (window_bindings.js:486:16)
at HTMLLIElement.element.onclick (file:///C:/../AppData/Local/Temp/nw3528_1882/js/script.js:29:12)
【问题讨论】:
-
您可以将参数附加到 URL,例如 GET 请求:
listdir.html?param1=value1&param2=value2 -
是的,我当然可以这样做,我只是期待有一种更动态的方式。
-
您可以使用“全局”变量在窗口之间共享任何内容,包括函数。 github.com/rogerwang/node-webkit/wiki/…
标签: javascript windows node.js node-webkit