Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to focus opener window in Chrome?

Focus opener window not working in Chrome...

Example 1.

popunder=window.open('http://google.com','asdf','width=800,height=800');
popunder.blur();
popunder.opener.window.focus();

Example 2.

popunder=window.open('http://google.com','asdf','width=800,height=800');
popunder.blur();

x = popunder.window.open('about:blank');
x.close();

popunder.opener.window.focus();

Example 3.

popunder=window.open('http://google.com','asdf','width=800,height=800');
popunder.blur();
window.focus();

Example ... and so on.

Does anyone know a solution that works?

like image 319
rjanjic Avatar asked Dec 28 '12 15:12

rjanjic


1 Answers

The only solution that currently works in Chrome is this code inside new window:

$(".closeBtn").click( function(e) 
{
    window.open("",window.opener.name);
});

Unfortunately the solution only works under two conditions:

  • window.opener has to have it's name set on document load (window.name="WhateverName";)
  • window.open() is called on user click
like image 104
Matej Balantič Avatar answered Oct 05 '22 23:10

Matej Balantič