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.
精彩评论