How can I open a new tab using javascript without switching to the new tab? For example, when a user clicks on a link a new tab is to be opened, but the user should stay
(function(a) { document.body.appendChild(a); a.setAttribute('href', location.href); a.dispatchEvent((function(e) { e.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, true, false, false, false, 0, null); return e }(document.createEvent('MouseEvents')))) }(document.createElement('a')))