0

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 :-)

Community
  • 1
  • 1
Zaveed Abbasi
  • 446
  • 1
  • 12
  • 34
  • Possible duplicate of http://stackoverflow.com/questions/10812628/open-a-new-tab-in-the-background – Zachary Dow Aug 20 '15 at 19:59
  • @ZacharyDow i have tried this solution but it didn't worked for me. and if u look at the JSFiddle mentioned in the question, it also doesn't work as described, rather the new tab gets the focus – Zaveed Abbasi Aug 20 '15 at 20:40
  • You're right. It looks like the functionality was deprecated. Still, it's the same question, just with poor solutions that don't work anymore :) – Zachary Dow Aug 20 '15 at 20:59
  • Hey, FWIW I found this while trying to figure out how to do this as it seems to be more and more blocked by browser design. http://ux.stackexchange.com/questions/15001/pop-under-really-that-bad – Zachary Dow Aug 21 '15 at 19:01

0 Answers0