Answer the question
In order to leave comments, you need to log in
How to open a tab in chrome without losing focus on the current tab?
broken code example:
window.open("ya.ru", "_blank").blur();
window.focus();
Answer the question
In order to leave comments, you need to log in
But it works for chrome like a current.
function openNewBackgroundTab(){
var a = document.createElement("a");
a.href = window.location.pathname;
var evt = document.createEvent("MouseEvents");
//the tenth parameter of initMouseEvent sets ctrl key
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0,
true, false, false, false, 0, null);
a.dispatchEvent(evt);
}
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
if(!is_chrome)
{
var url = window.location.pathname;
var win = window.open(url, '_blank');
} else {
openNewBackgroundTab();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question