如何从 XULRunner 中的 XUL 应用程序启动网页? [英] How do I launch a webpage from a XUL app within XULRunner?
本文介绍了如何从 XULRunner 中的 XUL 应用程序启动网页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
与以下按钮处理程序等效的 XULRunner 是什么?
What is the XULRunner equivalent of the following button handler?
function launch_page() {
var win = Components.classes['@mozilla.org/appshell/window-mediator;1']
.getService(Components.interfaces.nsIWindowMediator)
.getMostRecentWindow('navigator:browser');
win.openUILinkIn('http://www.google.com', 'window');
}
这不会在我使用 XULRunner --install-app ./foo.xpi 安装到 Program Files 的 XUL 应用程序中执行任何操作.
This does not do anything in my XUL app that's installed to Program Files using XULRunner --install-app ./foo.xpi.
我的 XUL 应用有什么方法可以启动用户的默认浏览器以在单击按钮时显示网页?
Is there any way for my XUL app to launch the user's default browser to display a web page on a button click?
推荐答案
这个现在有效:
// first construct an nsIURI object using the ioservice
var ioservice = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var uriToOpen = ioservice.newURI("http://www.google.com/", null, null);
var extps = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"]
.getService(Components.interfaces.nsIExternalProtocolService);
// now, open it!
extps.loadURI(uriToOpen, null);
有人有更标准的方法吗?
Anybody got a more standard way?
这篇关于如何从 XULRunner 中的 XUL 应用程序启动网页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文