Binding jQuery event on a child window

前端 未结 1 1487
长情又很酷
长情又很酷 2021-01-28 21:44

I have a page that has the following javascript:

var w = window.open(\"somePage.html\", \'\', \'width=500, height=500\');
$(w).bind(\'someEvent\', function() { a         


        
相关标签:
1条回答
  • 2021-01-28 22:33

    I think the problem is that $ still refers to the jquery in the host window. If you do this:

    var w = window.open("somePage.html", '', 'width=500, height=500');
    var $ = w.$;
    $(w).bind('someEvent', function() { alert('I see the event!'); });
    

    you should be good to go.

    0 讨论(0)
提交回复
热议问题