The NWJS documentation states that after opening a window, you have to wait for the loaded
event before you can interact with it:
You should wait for the Window’s
loaded
event before interacting with any of its components.
So I tried to add a loaded
event handler for the win object after opening it.
nw.Window.open('test.html', {}, (win) => {
win.showDevTools()
win.addEventListener("loaded", () => {
console.log("NW Window loaded not working...")
})
}
I get the following error:
Uncaught TypeError: win.addEventListener is not a function
How can I listen for NWWindow events in NWJS? Sidenote: I CAN listen for DOM window load events, but that's not the same is it?
nw.Window.open('test.html', options, (win) => {
win.showDevTools()
win.window.addEventListener("load", () => {
console.log("dom window load IS working...")
})
}
There is an example on how to use the Event Listener on the nw.Window:
Example from here, I changed it so that it fits to your problem