我需要用JavaScript在后台打开一个新窗口,并确保原始文档仍然集中 [英] I need to open a new window in the background with JavaScript, and make sure the original is still focused
问题描述
函数newwindow()
{
window.open('link.html','','width =,height =,resizable = no');
}
我需要它,一旦新窗口打开,焦点返回到原始窗口。
我该怎么做?
我在哪里把代码放在新窗口或旧窗口中?
Thanks!
这被称为'pop-under'但我离题)..它应该给你很多谷歌关于
你可能想要做类似的事情:
var popup = window.open(...);
popup.blur();
window.focus();
这应该将焦点设置回原始窗口(未经测试 - 从谷歌捏住)。一些浏览器可能会阻止这种技术。
I have a window I'm opening with a Javascript function:
function newwindow()
{
window.open('link.html','','width=,height=,resizable=no');
}
I need it that once the new window opens that the focus returns to the original window. How can I do that? And where do I put the code - in the new window, or the old one? Thanks!
This is known as a 'pop-under' (and is generally frowned upon... but I digress).. It should give you plenty to google about
You probably want to do something like:
var popup = window.open(...);
popup.blur();
window.focus();
Which should set the focus back to the original window (untested - pinched from google). Some browsers might block this technique.
这篇关于我需要用JavaScript在后台打开一个新窗口,并确保原始文档仍然集中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!