- This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Change the Iframe SRC Dynamically Without Triggering the Loading Spinner
How can I change the src
value on an iframe dynamically (or just insert a new iframe) without triggering the loading spinner? I know how to do that using window.onload
, but with buttons, I did not find any.
For example, see this blog (click the “reply” button!)
Using setTimeout
does not work.
function insert() {
setTimeout(function() {
document.getElementById('frameContainer').innerHTML = "";
}, 150);
}
PS: This forum have a little bug. Each
tag break all the
tag.
Almost solved: http://jsfiddle.net/tovic/kw7LD/22/
function insert() {
$('#container').html('');
$('#container iframe').one("load", function() {
$(this).attr('src', 'something.html');
});
}
@elneco: Ehm… still triggering the loading spinner :p
Works except in Google Chrome :D
<div id="container"></div>
<div id="iframe-holder">
<iframe src="" id="frame"></iframe>
</div>
function insert() {
var url = 'iframe-page.html',
holder = document.getElementById('iframe-holder'),
frame = holder.getElementsByTagName('iframe')[0];
frame.style.display = "block";
frame.src = url;
document.getElementById('container').insertBefore(holder, null);
}