在XUL中打开一个窗口

时间:2010-09-07 11:06:21

标签: xul xulrunner gecko

尝试在XUL中使用window.open打开窗口时会抛出异常。例外情况:Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMJSWindow.open]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location:

抛出异常的代码行是:

newWind = window.open(settings.url, "Dialog", "chrome = yes, width=" + 
          settings.width + ",height=" + settings.height + 
          ",resizable = yes,scrollbars=yes");

任何人都可以告诉我如何解决这个问题。

2 个答案:

答案 0 :(得分:2)

如果其他人有同样的问题,这里是答案: http://forums.mozillazine.org/viewtopic.php?t=421261

如果你在prefs.js中有一行像这样: pref(“toolkit.defaultChromeURI”,“chrome://myapp/content/myapp.xul”);

你必须像这样添加另一行: pref(“browser.chromeURL”,“chrome://myapp/content/myapp.xul”);

答案 1 :(得分:0)

我有一个XULRunner应用程序。我的窗口打开如下:

  

var win = window.open(“about:blank”,window_name,“status = yes,scrollbars = yes,minimizable = yes,top = 5000,left = 1000,width = 1000,height = 625,resizable = yes ,对话框=无,标题栏=是“);

注意没有空格?尝试将其格式化,就像我的一样,它应该可以工作。

另一个提示:

  

通过以下方式将该窗口转换为chrome:

     

var chromewin = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIWebNavigation).QueryInterface(Components.interfaces.nsIDocShellTreeItem).rootTreeItem.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components。 interfaces.nsIDOMWindow);