admin管理员组文章数量:1289893
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 some site still manage to open a pop-up window and keep focus on your current window, even when this setting is switched off. How do they achieve this?
Additionally, I don't understand why .blur() and .focus() doesn't work when both pages reside on the same domain. According to this should work.
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 some site still manage to open a pop-up window and keep focus on your current window, even when this setting is switched off. How do they achieve this?
Additionally, I don't understand why .blur() and .focus() doesn't work when both pages reside on the same domain. According to http://support.mozilla./en-US/questions/806756#answer-167267 this should work.
Share Improve this question edited Nov 3, 2011 at 16:44 asked Nov 3, 2011 at 14:07 user338195user338195 4- Can you give us an example of the site that you saw ? it might not be a pop-up in the traditional sense - might well be a div within the page that looks like a pop-up – Manse Commented Nov 3, 2011 at 14:11
- Hi, PirateBay does it as soon as you click on any of their links. – user338195 Commented Nov 3, 2011 at 14:14
- Why support so old browser? Current Fx version is 8. – Wojciech Bednarski Commented Nov 9, 2011 at 1:33
- It's a requirement, not everybody updates to the newest version as soon as it es out. – user338195 Commented Nov 10, 2011 at 11:46
2 Answers
Reset to default 6 +100This works for me in Firefox and Chrome, in default settings (JSFiddle):
function popUnder(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.", 1024, 768);
}, false);
<div id="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.
http://support.mozilla./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
本文标签: javascriptWindow popupshow to get windowblur() or windowfocus() to work in FireFox 4Stack Overflow
版权声明:本文标题:javascript - Window popups - how to get window.blur() or window.focus() to work in FireFox 4? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741485635a2381390.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论