i am opening a new tab with
window.open(URL)
In the URL a PDF is being opened
It was working fine until my requirement changed now i have to open the URL
in the new tab in such a way that the focus stays on the parent Tab( the opener, the caller).
I have tried different Solutions to trigger and simulate ctrl + mouse Click
but with no success
starting from window.focus
and window.opener.focus
to
function openBackgroundTab(){
window.open('<% =Session("PDFPrintPath")%>');
}
var e = jQuery.Event("click");
e.ctrlKey = true;
$('#btnFocusOnTab').bind("click",function(e){openBackgroundTab()});
$('#btnFocusOnTab').click();
and
function openBackgroundTab(){
var a = document.createElement("a");
a.href = '<% =Session("PDFPrintPath")%>';
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, true, false, false, false, 0, null);
a.dispatchEvent(evt);
return false;
}
document.getElementById("btnFocusOnTab").addEventListener("click", openBackgroundTab, false);
document.getElementById("btnFocusOnTab").click();
mentioned in mentioned as duplicate by @ZocharyDow
if any one can get me a solution, i will praise and preach his geniusness for ages :-)