我正在使用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');
而
myWindow=window.open('','','width=200,height=100')
myWindow.document.write("<p>This is 'myWindow'</p>")
myWindow.focus()
但我总是会遇到这个错误
[异常... "The operation is insecure." code: "18" nsresult: "0x80530012 (SecurityError)"
有没有办法处理这个异常?