如何让 SWT 浏览器控件在 Windows 上使用 Mozilla 而不是 IE? [英] How to make SWT Browser control use Mozilla instead of IE on Windows?
本文介绍了如何让 SWT 浏览器控件在 Windows 上使用 Mozilla 而不是 IE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想让 SWT 在我运行我的应用程序的所有平台上使用 Firefox.但 SWT 当然默认在 Windows 上使用 IE.知道如何让 SWT 在 Windows 上使用 Mozilla.我知道我需要在机器上安装 XULRunner.
I want to make SWT use Firefox on all platforms I run my app on. But SWT of course used IE on Windows by default. Any idea how to make SWT use Mozilla on windows. I know that I need to have XULRunner installed on the machine.
推荐答案
你问的很有趣 - 我只是需要在我们的项目中使用相同的方案.
Funny you've asked - I just needed the same for our project.
- 转到 ATF 站点 (http://wiki.eclipse.org/ATF/Installing) - 有如何从 Zend 站点 d/l XUL Runner.
- 此代码将使您无需注册 XULRunner 即可运行浏览器:
- Go to ATF site (http://wiki.eclipse.org/ATF/Installing) - there's how to d/l XUL Runner from Zend site.
- This code will let you run the browser without registering the XULRunner:
代码:
Bundle bundle = Platform.getBundle("org.mozilla.xulrunner"); //$NON-NLS-1$
if (bundle != null)
{
URL resourceUrl = bundle.getResource("xulrunner"); //$NON-NLS-1$
if (resourceUrl != null) {
try {
URL fileUrl = FileLocator.toFileURL(resourceUrl);
File file = new File(fileUrl.toURI());
System.setProperty("org.eclipse.swt.browser.XULRunnerPath",file.getAbsolutePath()); //$NON-NLS-1$
} catch (IOException e) {
// log the exception
} catch (URISyntaxException e) {
// log the exception
}
}
}
这里有更多详细信息:http://www.eclipse.org/swt/faq.php#howusemozilla
注意:我的代码与常见问题解答(不同的插件 ID)略有不同 - 我是这样工作的.
Note: my code is slightly different from FAQ (different plugin ID) - i works for me this way.
这篇关于如何让 SWT 浏览器控件在 Windows 上使用 Mozilla 而不是 IE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文