1

I use a toolbar button in Firefox to toggle between normal and private windows. Here is the code:

OpenBrowserWindow({private: !PrivateBrowsingUtils.isWindowPrivate(window)});
setTimeout(BrowserTryToCloseWindow, 80);

I use 'setTimeout' in order to prevent some flickering.

When the new window opens, it gets the focus. When the command 'BrowserTryToCloseWindow' is executed, the focus returns to the old window. When the old window is closed, the new one does have the focus, but it isn't 'checked / active' in Windows Task Bar.

I suppose I need to use ITaskbarList::ActivateTab in order to activate the new window in the task bar. I have the (very) basic direction:

Components.utils.import("resource://gre/modules/ctypes.jsm");
var lib = ctypes.open("user32.dll");
var taskBar = lib.declare(---
taskBar---
lib.close();

I'd appreciate your help.

Win 7, 32-bit, Classic Theme.

Posted here too.

1 Answer 1

1
function togglePB(click)

{ var newWin = OpenBrowserWindow({ private: ! PrivateBrowsingUtils.isWindowPrivate(window) });

if(click.button == 0)
    newWin.addEventListener("focus",  function switchWindows() { window.focus(); BrowserTryToCloseWindow(); newWin.removeEventListener("focus", switchWindows); });

}

http://forums.mozillazine.org/viewtopic.php?f=19&t=2895755

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .