I want to load an iframe into a bootstrap modal and show a loader before the iframe is loaded. I am using a simple jquery click function, but it is not working. I do not understand why it is not working. fiddle full page fiddle
$('.btn').click(function() {
$('.modal').on('show',function() {
$(this).find('iframe').attr('src','http://www.google.com')
})
$('.modal').modal({show:true})
$('iframe').load(function() {
$('.loading').hide();
});
})
Bootstrap event for modal load was changed in Bootstrap 3
just use
shown.bs.modal
event:More can found on the event at the below link:
http://getbootstrap.com/javascript/
You can simply use this bootstrap helper to dialogs (only 5 kB)
it has support for ajax request, iframes, common dialogs, confirm and prompt!
you can use it as:
this provide a loading progress while loading the iframe!
No html required.
You can use a object literal as parameter to extra options.
Check the site form more details.
best,
As shown above use
'shown.bs.modal'
event which comes in bootstrap 3.EDIT :-
and just try to open some other url from iframe other than google.com ,it will not allow you to open google.com due to some security threats.
The reason for this is, that Google is sending an "X-Frame-Options: SAMEORIGIN" response header. This option prevents the browser from displaying iFrames that are not hosted on the same domain as the parent page.
I came across this implementation in Codepen. I hope you find it helpful.
It seems that your
You can do this in a slight different way, like this