Javascript - load events for embed elements

前端 未结 5 1114
感情败类
感情败类 2020-12-19 01:37

If I do an online onload event for embed objects, that seems to work but I can\'t seem to get the load event working through addEventListener. Is this expected?

相关标签:
5条回答
  • 2020-12-19 02:11

    could always set like this:

    document.getElementById("objectId").onload = function(){ ... }
    
    0 讨论(0)
  • 2020-12-19 02:22

    jQuery is perhaps the best way to go with this.

    $("embed").load(function(){
       // enter code here
    })
    
    0 讨论(0)
  • 2020-12-19 02:22

    jQuery on/bind/load won't be fired for embed elements, while ready works but not after rendered when using Chrome, if you want to listen to the stage after rendering embeded elements, you may have to use pure js to add handlers.

    0 讨论(0)
  • 2020-12-19 02:23

    Probably, but it may be browser dependent.

    windows and images and iframes define their load events with addEventListener and attachEvent, but other load events are browser specific.

    A script or link element's onload doesn't attach in IE, for instance.

    0 讨论(0)
  • 2020-12-19 02:33

    try

    $("embed").ready(function(){ ... });

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