0

Im sorry if I havent done my research properly, - but couldnt find the answer I needed, so here goes:

From my main page I open a new window using mainPlayer = window.open();

This window stays open until user clicks on a mainPlayer.close(); event. (or simply x closes the window)

However, the idea is to make it possible to let the player keep playing, while browsing around the rest of the pages.

But as soon as the user leaves the page that opened the mainPlayer window, the reference to the mainPlayer window seem to be lost.

How do I, from the site's other pages, check if the mainPlayer window is open and close it on a click event?

Thx John

Edit

I checked this thread: Find window previously opened by window.open And did as the answer suggested, with no luck. But perhaps I am misunderstanding the idea.

What I did was:

I created

function tjek_ClosePlayer()
{
var playerUrl = 'custom_inserts/custom_player.php';
var mainPlayer= window.open('', 'mainPLayer', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=605, height=100') ;
if(mainPLayer.location == 'about:blank' ){ mainPlayer.location = playerUrl ; }
mainPLayer.close();
}

And then called the function, onclick, from the refreshed page. No luck.

Anyone?

Community
  • 1
  • 1

1 Answers1

0

When you close the parent window, reference to the popup will indeed be destroyed. I guess this is something that cannot be controlled via code.

One thing you can do is write out a cookie when opening the popup, which the popup can check periodically and act upon.

For ex: write out a cookie named X='opened' before opening the popup. In the popup periodically check for the value of X and once it is found to be equal to 'close', delete the cookie and close the popup window - via window.close()

Note: this will be easier if you have the parent page(s) as well as the popup page served from the same domain.

techfoobar
  • 65,616
  • 14
  • 114
  • 135
  • Yea... but I would have to make it check pretty much every second - for that to be even remotely effective. And even then it would be a faily slow player-turnoff.... – John Kjøller Sep 06 '12 at 16:48
  • *Actually* checking the value of the cookie every second wont make it inefficient or unresponsive. Infact its nothing compared to the kind of abuse people put timers to. :-) – techfoobar Sep 06 '12 at 17:26