Reputation: 81
I'm trying to use new-win-policy
event to handle link clicks that open new windows. https://github.com/rogerwang/node-webkit/wiki/Window#new-win-policy
win.on('new-win-policy', newWinPolicyHandler);
function newWinPolicyHandler(frame, url, policy) {
gui.Window.open(url, {
position: 'center',
frame: true,
toolbar: true,
focus: true
});
policy.ignore();
}
After click on a link the handler isn't called. I got the message in console:
[17120:1029/214512:INFO:CONSOLE(138)] ""Remove zombie callback for window id 1 ev: new-win-policy"", source: window_bindings.js (138)
Have no idea what to do...
Upvotes: 2
Views: 1746
Reputation: 79
Thanks very much for posting your question. Info on doing this seems scarce. I was able to try out some variations based upon your sample. In my case I'm using an iFrame in NWJS, and was able to prevent popups, forcing the URL into the iFrame:
win.on('new-win-policy', newWinPolicyHandler);
function newWinPolicyHandler(frame, url, policy) {
policy.ignore(); //ignore policy first to prevent popup
$("#Your-iFrameID").attr("src",url); //load popup url into iFrame
}
Upvotes: 1