dynamically created iframe triggers onload event twice

前端 未结 6 1873
鱼传尺愫
鱼传尺愫 2020-12-14 06:50

I created an iframe dynamically and found that this iframe trigger onload event twice.

var i=0;
frameOnload=function(){
  console.log(i++);  
};

var ifr=doc         


        
6条回答
  •  一生所求
    2020-12-14 07:39

    I've had this happen to asynchronously loaded stylesheets, like this one.

    
    

    I find that the simplest solution is to have the event remove itself:

    
    

提交回复
热议问题