js open popup window and acces its element in another page

前端 未结 1 735
庸人自扰
庸人自扰 2020-12-16 04:58

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,

相关标签:
1条回答
  • 2020-12-16 05:53

    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();
    
    0 讨论(0)
提交回复
热议问题