我在Windows 7上使用jxbrowser 4.9,当一个链接有一个目标=" _blank"并指向pdf,
pdf插件即将推出一个新的弹出窗口,
因为我想下载这个pdf,我通过
禁用了该弹出窗口中的pdf插件PluginManager pluginManager = browser.getPluginManager();
pluginManager.setPluginFilter(new PluginFilter() {
@Override
public boolean isPluginAllowed(PluginInfo pluginInfo) {
return false;
}
});
弹出窗口显示黑屏,其中"无法加载插件"但不提供我下载pdf。
如果我更改链接以禁止目标=" _blank",并禁用pdf插件,则可以下载pdf。
当target =" _blank"?
时,有什么特别要做的事情来下载PDF感谢您的帮助!
这是我的简单课程: 公共类TestPopupPDF {
/**
* @param args
*/
public static void main(String[] args) throws Exception {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
initAndDisplayUI();
}
});
}
private static void initAndDisplayUI() {
Browser browser = BrowserFactory.create();
JFrame frame = new JFrame("JxBrowser - Popup PDF test");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.add(browser.getView().getComponent(), BorderLayout.CENTER);
frame.setSize(500, 400);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
PluginManager pluginManager = browser.getPluginManager();
pluginManager.setPluginFilter(new PluginFilter() {
@Override
public boolean isPluginAllowed(PluginInfo pluginInfo) {
//disable all plugins
return false;
}
});
browser.setPopupHandler(new PopupHandler() {
public PopupContainer handlePopup(PopupParams params) {
return new PopupContainer() {
public void insertBrowser(final Browser browser,
Rectangle initialBounds) {
initialBounds.setBounds(100, 100, 500, 400);
JComponent component = browser.getView().getComponent();
component.setPreferredSize(initialBounds.getSize());
final JFrame frame = new JFrame("Popup");
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frame.add(component, BorderLayout.CENTER);
frame.pack();
frame.setLocation(initialBounds.getLocation());
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
browser.dispose();
}
});
PluginManager pluginManager = browser.getPluginManager();
pluginManager.setPluginFilter(new PluginFilter() {
@Override
public boolean isPluginAllowed(PluginInfo pluginInfo) {
return false;
}
});
}
};
}
});
browser.loadURL("http://localhost/test.html");
}
}
这是test.html页面:
<html>
<head></head>
<body>
<H1>PDF</H1>
<a href="javascript.pdf" target="_blank">download/open pdf file new page</a>
<br><br>
<a href="javascript.pdf">download/open pdf file same page</a>
</body>
</html>
使用任何pdf。