gpt4 book ai didi

javascript - 火狐javascript window.open _self

转载 作者:行者123 更新时间:2023-11-30 17:50:15 24 4
gpt4 key购买 nike

我的问题是:
当我使用时:

window.open("example.com","_self");

self.open("example.com");

window.location.href="example.com";

Firefox 删除所有菜单、按钮、窗口的窗口最小化按钮,一切。上下文菜单也停止工作,但网站打开正常,除了这种困惑,这毁了一切。

那么如何解决这个问题呢?

编辑:我正在使用 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'");

最佳答案

gBrowser.loadURI('http://www.example.com');

正常工作。

关于javascript - 火狐javascript window.open _self,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19177500/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com