Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
307 views
Welcome To Ask or Share your Answers For Others

1 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...