Note: Advice in this article will only work for JxBrowser 6. See the corresponding article for JxBrowser 7 here.(注意:本文中的建议仅适用于JxBrowser6,JxBrowser7相应文章请点击这里。)


Any web page can display pop-up windows using the window.open() JavaScript function. For example: (任何网页都可以使用window.open()JavaScript函数显示弹出窗口。例如:)

window.open("http://www.google.com", "_blank", "toolbar=yes, 
    scrollbars=yes, resizable=yes, top=500, left=500, width=400, height=400");

Note: by default, pop-up windows are enabled and displayed in both Swing and JavaFX UI toolkits.(注意:默认情况下,在Swing和JavaFX UI工具箱中都启用并显示弹出窗口。)


JxBrowser API provides the PopupHandler class to handle pop-up windows creation. To handle pop-up windows creation you must register your own implementation of PopupHandler depending on GUI toolkit you use in your Java application. To get more information about how to handle pop-ups in Swing and JavaFX toolkits take a look at the following articles:(JxBrowser API提供PopupHandler类来处理弹出窗口的创建。要处理弹出窗口,您必须根据在Java应用程序中使用的GUI工具包,注册自己的PopupHandler实现。要获得有关如何处理Swing和JavaFX工具箱中的弹出窗口的更多信息,请查看以下文章:)


Disabling Popups(禁用弹出窗口)

To disable pop-up windows you must create and register your own implementation of PopupHandler and return null from the handlePopup() method as shown below: (要禁用弹出窗口,必须创建并注册自己的PopupHandler实现,并从handlePopup()方法返回null,如下所示:)

browser.setPopupHandler(new PopupHandler() {
    public PopupContainer handlePopup(PopupParams params) {
        return null;
    }
});