我的问题是:
当我使用:
window.open("example.com","_self");或
self.open("example.com");或
window.location.href="example.com";火狐删除所有菜单,按钮,窗口的窗口最小化按钮,所有东西。也是上下文菜单停止工作,但网站打开良好,除了这种混乱,这破坏了一切。
那怎么解决这个问题?
编辑:--我在使用FF22,新安装。看起来这不是一个简单的例子,所以我在这里删除了整个代码,它是为从上下文菜单创建新选项卡而略作编辑的注释:
let _ = require("l10n").get;
let winUtils = require("window-utils");
let { isBrowser } = require("api-utils/window/utils");
var delegate = {
onTrack: function (window) {
if (isBrowser(window) ){
let menu = window.document.getElementById("tabContextMenu");
let newtab = window.document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul","menuitem");
newtab.setAttribute("id", "contexttab-newtab");
newtab.setAttribute("label", _("newtab_string"));
newtab.setAttribute("accesskey", _("newtabaccesskey_string"));
newtab.setAttribute("oncommand", "window.location.href='http://www.example.com'");
menu.insertBefore(newtab, menu.firstChild);
} // End isBrowser
} // End ontrack
} // End delegate function
let tracker = new winUtils.WindowTracker(delegate);
// code to remove the menuitem when extension is disabled for satisfy requirement on AMO for pass a full review
// On uninstall the menuitem is not removed, see: https://bugzilla.mozilla.org/show_bug.cgi?id=627432
exports.onUnload = function(reason) {
var unloader = {
onTrack: function (window) {
if (isBrowser(window) ){
let menu = window.document.getElementById("tabContextMenu");
let newtab = window.document.getElementById("contexttab-newtab");
menu.removeChild(newtab);
}
}
}; // End unloader function
let remover = new winUtils.WindowTracker(unloader);
}这是我编辑的唯一一行:
newtab.setAttribute("oncommand", "window.location.href='http://www.example.com'");发布于 2013-10-06 09:31:54
gBrowser.loadURI('http://www.example.com');正常工作。
发布于 2014-07-21 21:12:19
gBrowser.loadURI将页面加载到选定的选项卡中,我认为。
如果您想打开一个新窗口,您必须这样做:
var url = Cc['@mozilla.org/supports-string;1'].createInstance(Ci.nsISupportsString);
url.data = 'http://www.bing.com/';
Services.ww.openWindow(null, 'chrome://browser/content/browser.xul', '_blank', 'chrome,all', url);https://stackoverflow.com/questions/19177500
复制相似问题