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?
Insert a button into the Orders List page grid. Show the Add page in a popup, close popup on clicking 'Save', and then refresh the List page. There is an added button to the List page that displays the Add page in a popup.
Open UiExplorer, and get the selector of that popup. Use an On Element Appear activity, put in the selector of that popup. in the On element Appear activity, place a Get Attribute activity, “url” to get the url of the popup.
You can have multiple popups by changing the popup window name (pass the ID string as a second parameter, and make the ID the popup name, for example). They'll stay open, but they will not all stay on top of the main page.
You can simply use <iframe> to display the another page content in the modal content.
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
<script>
var w = window.open("p.htm", "playerWin", "width=300,height=130");
</script>
<a href="2.htm">2</a>
p.htm
<a href="javascript:opener.w=this;">re-link</a>
2.htm
<script>
var w;
</script>
<a href="javascript:alert(w);">check</a>
The answer is no. Most browsers will completely isolate the window and document from one navigation to the next. There is no where you could place the reference to the popup which will survive when you navigate to page2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With