新选项卡中的打开窗口忽略浏览器设置 [英] open window in new tab ignores browser setting
本文介绍了新选项卡中的打开窗口忽略浏览器设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在新标签页面中打开窗口,我需要将焦点保留在原始页面(而不是新标签页)上。这也是浏览器设置。
知道怎么做吗?
I would like to open window in a new tab and I need a focus to remain on the original page (not the new tab). This is browser setting as well.
Any idea how to do it?
window.open(url, '_blank');
window.focus();
不是解决方案,这将在新窗口中打开一个选项卡,但焦点将移动到新选项卡。
is not the solution, this opens a tab in new window but the focus is moved to new tab.
推荐答案
您需要使用window.open的返回值来设置焦点,像这样:
You need to use the return value of window.open to set the focus, like this:
var wnd = window.open(url, '_blank');
wnd.focus();
祝你好运!
Good luck!
这篇关于新选项卡中的打开窗口忽略浏览器设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文