Opening a window in XUL

泪湿孤枕 提交于 2020-01-06 08:15:56

问题


An exception is being thrown when trying to open a window using window.open in XUL. The exception details: Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMJSWindow.open]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location:

The line of code throwing the exception is:

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

Can anyone please tell me how to get round this problem.


回答1:


In case someone else has the same problem here is the answer: http://forums.mozillazine.org/viewtopic.php?t=421261

If you have a line in prefs.js like this: pref("toolkit.defaultChromeURI", "chrome://myapp/content/myapp.xul");

you have to add another one line like this: pref("browser.chromeURL", "chrome://myapp/content/myapp.xul");




回答2:


I have an XULRunner app. my window open line is as follows:

var win = window.open("about:blank", window_name, "status=yes,scrollbars=yes,minimizable=yes,top=5000,left=1000,width=1000,height=625,resizable=yes,dialog=no,titlebar=yes");

Notice how there are no spaces? Try formatting it exactly like mine is and it SHOULD work.

Another tip:

Convert that window to chrome, via:

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



来源:https://stackoverflow.com/questions/3658071/opening-a-window-in-xul

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!