You may try this (using jQuery
)
$(function(){_x000D_
$('#MainPopupIframe').load(function(){_x000D_
$(this).show();_x000D_
console.log('iframe loaded successfully')_x000D_
});_x000D_
_x000D_
$('#click').on('click', function(){_x000D_
$('#MainPopupIframe').attr('src', 'https://heera.it'); _x000D_
});_x000D_
});
_x000D_
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>_x000D_
<button id='click'>click me</button>_x000D_
_x000D_
<iframe style="display:none" id='MainPopupIframe' src='' /></iframe>
_x000D_
Update: Using plain javascript
window.onload=function(){_x000D_
var ifr=document.getElementById('MainPopupIframe');_x000D_
ifr.onload=function(){_x000D_
this.style.display='block';_x000D_
console.log('laod the iframe')_x000D_
};_x000D_
var btn=document.getElementById('click'); _x000D_
btn.onclick=function(){_x000D_
ifr.src='https://heera.it'; _x000D_
};_x000D_
};
_x000D_
<button id='click'>click me</button>_x000D_
_x000D_
<iframe style="display:none" id='MainPopupIframe' src='' /></iframe>
_x000D_
Update: Also you can try this (dynamic iframe)
$(function(){_x000D_
$('#click').on('click', function(){_x000D_
var ifr=$('<iframe/>', {_x000D_
id:'MainPopupIframe',_x000D_
src:'https://heera.it',_x000D_
style:'display:none;width:320px;height:400px',_x000D_
load:function(){_x000D_
$(this).show();_x000D_
alert('iframe loaded !');_x000D_
}_x000D_
});_x000D_
$('body').append(ifr); _x000D_
});_x000D_
});
_x000D_
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>_x000D_
<button id='click'>click me</button><br />
_x000D_