Window Popups - How To Get Window.blur() Or Window.focus() To Work In Firefox 4?
I'm aware that FF4 doesn't allow the use of window.blur() unless 'Raise or lower window' setting is enabled in the FF configuration. It simple ignores the event. I'm aware that som
Solution 1:
This works for me in Firefox and Chrome, in default settings (JSFiddle):
functionpopUnder(url, width, height) {
var popUnderWin, nav = navigator.userAgent,
isGecko = /rv:[2-9]/.exec(nav),
hackString;
hackString = nav.indexOf('Chrome') > -1 ? "scrollbar=yes" : "toolbar=0,statusbar=1,resizable=1,scrollbars=0,menubar=0,location=1,directories=0";
popUnderWin = window.open("about:blank", "title", hackString + ",height=" + height + ",width=" + width);
if (isGecko) {
popUnderWin.window.open("about:blank").close();
}
popUnderWin.document.location.href = url;
setTimeout(window.focus);
window.focus();
popUnderWin.blur();
}
document.getElementById("asd").addEventListener("click", function() {
popUnder("http://www.google.com", 1024, 768);
}, false);
<divid="asd">click here</div>
I didn't manage to get it work without the hacky extra parameters to window.open
, so there is something to them.
Solution 2:
http://support.mozilla.com/en-US/questions/806756#answer-167267
They say that it isn't possible unless everybody goes to about:config
and sets dom.disable_window_flip
to false
.
I am not aware of any code that bypasses this restriction but I think the other websites use something other than window.blur()
and window.focus()
There is a similar article here
Post a Comment for "Window Popups - How To Get Window.blur() Or Window.focus() To Work In Firefox 4?"