jQuery onload - .load() - event not working with a dynamically loaded iframe

后端 未结 4 1762
忘了有多久
忘了有多久 2021-01-02 00:15

My script loads an iframe when the user clicks a button. I want to call another function after the iframe loads, but it\'s not working. The iframe does load normally, but

4条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-02 00:18

    Try this:

    $("").appendTo("body")
        .attr('src', url)
        .load(function() 
         {
             callback(this);
         });
    

    Just added some chaining, created the element where the selector usually goes (this is possible), and appended it to the body.

提交回复
热议问题