Add onload event handler on dynamically created iframe component in lightning

Add onload event handler on dynamically created iframe component in lightning-



We need to bind event dynamically with component.getreference. then we can reference another function in the controller like


$A.createComponent(

  'iframe',

  {

    'aura:id': 'iframe',

    src: iframeUrl,

    onload:component.getReference('c.handleiframeonload');

  },);


handleiframeonload : function(cmp,evt,hel){

// write your onload logic here.

}

Comments