firefox javascript window.open _self
firefox javascript window.open _self
我的问题是:
当我使用:
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');
工作正常。
我认为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);
相关文章:
- 直接下载文件,而不是从window.open(url)
- document.open/document.write没有正确地清除chrome中的文档——这是chrome的错误吗
- 如何将PDF作为二进制文件传递到window.open()
- 为什么window.open不打开一个以变量形式给出的链接
- 如何在`window.open`之后执行回调
- 在JavaScript类型的函数中避免self-this
- Windows.Open 在 window.Location 工作时不起作用
- 在page.open()-PhantomJS中无法访问全局变量
- javascript window.open将无法在Chrome控制台上工作
- window.open根据动态内容自动调整高度和宽度
- window.open使页面向上滚动
- 替代'self=这个'带有javascript中的对象
- window.open(url).print()在Safari中不起作用
- Javascript window.open()toolbar=no不起作用
- window.open尽管被用户触发,但仍无法在InternetExplorer中工作
- $.ajax().done()中的window.open和弹出窗口拦截器
- XMLHttpRequest.open()AJAX中的参数url
- 如何在JS文件中添加wordpress permalink(onclick,window.open)
- window.open如何在Mozilla和IE中打开self
- 如何在弹出窗口中显示后退和前进按钮,通过 window.open 或 self.open 打开 Chrome