I got an iframe inside a modal which starts on "about:blank" and does get fed src's by jquery.
This works alright already, but when the iframe src is set to change, there is always a delay where the modal will still show the old content, while loading the new.
How can I instantly clear the iframe before a new src is given?
Here some code:
$(function() {
$('a.modal-k2-<?php echo $this->item->id; ?>').click(function() {
window.top.$('#modalHolderK2_title').text('<?php echo $author->name . ' - ' . $this->item->title; ?>');
if (window.top.$('#modalHolderK2_iframe').attr('src') != '<?php echo $itemlink; ?>') {
window.top.$('#modalHolderK2_iframe').attr('src','about:blank');
window.top.$('#modalHolderK2_iframe').attr('src','<?php echo $itemlink; ?>');
}
window.top.$('#modalHolderK2').modal();
return false;
});
});
It seems that the "window.top.$('#modalHolderK2_iframe').attr('src','about:blank);" is not executed fully before the new src is passed to the iframe.
I guess there is an easy solution but I didnt find anything which worked for me yet.
I just want to avoid the modal to show old content when a new one is called.
$("#iframe").contents().find("body").html('');
$('#iframid').attr('src', '');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With