I need to allow a user to click a link in ‘page-1.htm’ and open a popup window. Then, when the user browses to ‘page-2.htm’ in the main browser window I need to be able to reference the popup window.
JavaScript in ‘page-1.htm’
var playerWin = window.open('player.htm', 'playerWin', 'width=300,height=130'); playerWin.play('song.mp3'); // play() is a function in player.htm
JavaScript in ‘page-2.htm’
playerWin.play('tune.mp3');
This code in page-2.htm generates an error ‘playerWin is not defined’. That is understandable because no variable named playerWin has been defined on page-2.htm.
My question is: Am I able to reference the popup window from page-2.htm?
I just did a quick test even after you leave the opener page, the popup still have ‘opener’ object and you can access it. So either poll the opener and reset the reference, or add a timer after you leave the page to wait and then relink.
1.htm
p.htm
2.htm