0

I want to open a pop-up window using window.open() in JavaScript and immediately focus on the previous page (not the pop-up page). Are there any way I could do it?

Here is the code:

let newwin;
function pop(){
newwin = window.open("https://stackoverflow.com","_blank","width=500,height=500");
setTimeout(()=>{newwin.blur();},0);
}
I tried to use .blur() to achieve it, but seems not working.

Are there any ways I could do it or not?

Thanks for any responds!

James
  • 2,608
  • 2
  • 2
  • 23
  • 2
    Problem is it was abused a lot in the past so there are a lot of protections around this. You can try and focus the window.opener, but doubt it will make any difference. – epascarello Dec 22 '21 at 20:34

0 Answers0