jquerydomwindowready

jQuery: receive document ready() on child window


I'm trying to get notified when the child window I'm opening has its document loaded and ready. This doesn't seem to work:

win = window.open(href, 'test', 'width=300, height=400');
win.focus();
$(win.document).ready(function() {
           // Ok, the function will reach here but if I try to manipulate the
           // DOM it doesn't work unless I use breakpoints
           $(this).contents().find("...").doStuff(); // nothing happens
    });

What do I have to do?


Solution

  • Have you tried this? —

    $(win.document).ready(function() {
        $(win.document).contents().find("...").doStuff();
    });
    

    This question discusses something very similar. Duplicate?