简体   繁体   English

回调以确认在IFRame中设置了“ SRC”属性

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

Need to show the popup only when the data is loaded inside IFrame successfully. 仅当数据成功加载到IFrame中时才需要显示弹出窗口。 Currently popup gets visible even if the source of IFrame doesn't get loaded. 当前,即使未加载IFrame的源,弹出窗口也可见。 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. 请让我知道该回调,以确认在IFrame中设置了“ SRC”属性。

You should use jQuery as below:: 您应该使用jQuery ,如下所示:

$('#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. 我已经在JSFIDDLE中完成了此操作 ,请检查链接将为您提供帮助。 and modify it as your need. 并根据需要进行修改。 Link: https://jsfiddle.net/a1kj8883/ 链接: https//jsfiddle.net/a1kj8883/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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