我的問題是:
當我使用:Firefox的JavaScript的window.open _self
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'");
它會直接將您重定向到「example.com」這就是爲什麼它沒有顯示你的菜單和all..if你想在你的頁面的特定位置打開網址,你可以使用框架或種類在特定的地方打開網址。 –
你正在使用哪個版本的FF?我[無法重現](http://jsfiddle.net/Qeagx/)這與FF24。 – Teemu
我更新了第一篇文章。 – user2838984