首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >firefox window.open _self

firefox window.open _self
EN

Stack Overflow用户
提问于 2013-10-04 09:15:54
回答 2查看 2.7K关注 0票数 1

我的问题是:

当我使用:

代码语言:javascript
复制
window.open("example.com","_self");

代码语言:javascript
复制
self.open("example.com");

代码语言:javascript
复制
window.location.href="example.com";

火狐删除所有菜单,按钮,窗口的窗口最小化按钮,所有东西。也是上下文菜单停止工作,但网站打开良好,除了这种混乱,这破坏了一切。

那怎么解决这个问题?

编辑:--我在使用FF22,新安装。看起来这不是一个简单的例子,所以我在这里删除了整个代码,它是为从上下文菜单创建新选项卡而略作编辑的注释:

代码语言:javascript
复制
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);
}

这是我编辑的唯一一行:

代码语言:javascript
复制
newtab.setAttribute("oncommand", "window.location.href='http://www.example.com'");
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-10-06 09:31:54

代码语言:javascript
复制
gBrowser.loadURI('http://www.example.com');

正常工作。

票数 2
EN

Stack Overflow用户

发布于 2014-07-21 21:12:19

gBrowser.loadURI将页面加载到选定的选项卡中,我认为。

如果您想打开一个新窗口,您必须这样做:

代码语言:javascript
复制
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);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19177500

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档