Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

js open popup window and acces its element in another page

I have a problem with js popup window.

I open a popup and try to access its elements in another page page, no success, and I don't want to reload the popup source, I simply want access a element of the opened popup

Ex -

  • 1st page - opened popup with html5 music player
  • 2nd page - need to pause the music when user click on button on main page

1st page

var popup = window.open("test.html","mypopup","width=500,height=300");

2nd page I want to access mypopup windows elements without reloading the popup

I only need the way how to access opened popup elements without interrupting its sources using JS or JQuery

like image 389
Suneth Kalhara Avatar asked May 06 '12 04:05

Suneth Kalhara


1 Answers

Same origin (domain, port and protocol)?

Plain JS:

from page1

var popup = window.open("test.html","mypopup","width=500,height=300");
popup.document.getElementById("player").someFunction();

from page 2

var popup = window.open('','mypopup');
// now popup is known again
popup.document.getElementById("player").someFunction();
like image 107
mplungjan Avatar answered Sep 28 '22 06:09

mplungjan