Suneth Kalhara
Suneth Kalhara

Reputation: 1208

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

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

Upvotes: 9

Views: 27973

Answers (1)

mplungjan
mplungjan

Reputation: 178375

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();

Upvotes: 12

Related Questions