开发者

jQuery: open window and attach a submit() callback to the opened window's document form

Hey, on a page I have a link which opens up a new window displaying a form.

function open_window(href)
{
   win = window.open开发者_高级运维(href, '', 'width=300, height=400');

   $(win.document).ready(function() {  
      $(win.document).contents().find("#links_form").submit(function(){alert(77);});
   });      
}

But when I press the submit button nothing's happening but if I put the same line of code

$(win.document).contents().find("#links_form").submit(function(){alert(77);});

in the firebug console (main window) everything works and the submit() callback attaches itself. What am I missing?


$(win.document).contents()

Change to

this.contents()

win isn't available inside the ready function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜