简体   繁体   中英

Callback to confirm that “SRC” attribute is set in IFRame

Need to show the popup only when the data is loaded inside IFrame successfully. Currently popup gets visible even if the source of IFrame doesn't get loaded. Here is the code snippet:

$('#myIframe').attr('src', 'Student.aspx?roll=' + rollNumber);
$('#studentInfoPopup').modal('show');

I tried with the following, but it didn't work:

$("#myIframe").load(function(){
      $('#studentInfoPopup').modal('show');
}).attr('src', 'Student.aspx?roll=' + rollNumber);

Kindly let me know the callback to confirm that "SRC" attribute is set in IFrame.

You should use jQuery as below::

$('#myIframe').attr('src', 'Student.aspx?roll=' + rollNumber);
$('#myIframe').load(function(){
  $('#studentInfoPopup').modal('show');
});

UPDATED:
I have done this in JSFIDDLE , please check the link it will help you. and modify it as your need. Link: https://jsfiddle.net/a1kj8883/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM