如何正确处理在node-webkit中打开_blank窗口的链接? [英] How to handle links that open _blank windows in node-webkit properly?

查看:77
本文介绍了如何正确处理在node-webkit中打开_blank窗口的链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用new-win-policy事件来处理打开新窗口的链接单击. https://github.com/rogerwang/node-webkit/wiki/Window#new-win-policy

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...

推荐答案

非常感谢您发布问题.有关执行此操作的信息似乎很少.我能够根据您的样本尝试一些变体.就我而言,我在NWJS中使用iFrame,并且能够阻止弹出窗口,从而将URL强制插入iFrame:

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
}

这篇关于如何正确处理在node-webkit中打开_blank窗口的链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆