How can I detect whether an iframe is loaded? How can I detect whether an iframe is loaded? jquery jquery

How can I detect whether an iframe is loaded?


You may try this (using jQuery)

$(function(){    $('#MainPopupIframe').load(function(){        $(this).show();        console.log('iframe loaded successfully')    });            $('#click').on('click', function(){        $('#MainPopupIframe').attr('src', 'https://heera.it');        });});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><button id='click'>click me</button><iframe style="display:none" id='MainPopupIframe' src='' /></iframe>