相关疑难解决方法(0)

打开一个新的标签/窗口并写一些内容?

我正在使用Execute JS在Firefox中编写和测试Javascript代码.我想打开一个新的标签/窗口并写一些东西,我试过了

var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);
var win = wm.getMostRecentWindow("navigator:browser");
printWindow = win.open("about:blank");
printWindow = wm.getMostRecentWindow("navigator:browser");
printWindow.gBrowser.selectedBrowser.contentDocument.write('hello');
Run Code Online (Sandbox Code Playgroud)

myWindow=window.open('','','width=200,height=100')
myWindow.document.write("<p>This is 'myWindow'</p>")
myWindow.focus()
Run Code Online (Sandbox Code Playgroud)

但是我总是得到这个错误

[例外......"手术不安全." 代码:"18"nsresult:"0x80530012(SecurityError)"

有没有办法解决这个异常?

javascript firefox xpcom firefox-addon

13
推荐指数
2
解决办法
4万
查看次数

标签 统计

firefox ×1

firefox-addon ×1

javascript ×1

xpcom ×1