[好,所以我找不到这个答案,我试图打开一个窗口,在加载后执行命令,然后在主窗口中修改它的DOM。这是我的示例代码:
var window = window.open('empty.html',{
"position": "center",
"focus": true,
"toolbar": false,
"frame": true
});
...
window.on("loaded",function() {
...
不会开火。当我尝试
var a_window = window.open('empty.html',{
"position": "center",
"focus": true,
"toolbar": false,
"frame": true
});
a_window = gui.Window.get(a_window);
...
a_window.on("loaded",function() {
...
但是在这里它甚至都没有打开窗户! (不,我在回调函数中没有hide()函数),也不会引发任何错误。有帮助吗?
[尝试看看这是否有用,它对我有用:
var a_window = window.open('empty.html',{
"position": "center",
"focus": true,
"toolbar": false,
"frame": true
});
onload = function() {
alert('Help it\'s loaded!');
};
请注意,我认为每个窗口都会触发onload,因此请记住在不需要时将其取消设置:
onload = null;
您也可以在单个窗口中尝试此操作:
a_window.onload = function() {
alert('Help it\'s loaded!');
};
nw.Window.open
用打开的窗口回调第三个参数。nw.Window.get
将DOM窗口作为参数。
nw.Window.open('empty.html',{},win=>win.on('loaded', () =>someFunction(nw.Window.get(win.window))));