Note that there are some explanatory texts on larger screens.

plurals
  1. POfirefox javascript window.open _self
    primarykey
    data
    text
    <p>My problem is:<br> When I use:</p> <pre><code>window.open("example.com","_self"); </code></pre> <p>or</p> <pre><code>self.open("example.com"); </code></pre> <p>or</p> <pre><code>window.location.href="example.com"; </code></pre> <p>Firefox removes all menus, buttons, window's window minimization buttons, everything. Also context menu stop working, but site opens fine except this chaos, which ruins everything.</p> <p>So how to fix this?</p> <p><strong>EDIT:</strong> I'm using FF22, fresh install. Looks like its not a simple case so I drop here entire code, it's slightly edited addon for creating new tabs from context menu:</p> <pre><code>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); } </code></pre> <p>This is the only line I edited:</p> <pre><code>newtab.setAttribute("oncommand", "window.location.href='http://www.example.com'"); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload