Forums

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

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #38893
    Taufik Nurrohman
    Participant

    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.

    #106077
    Taufik Nurrohman
    Participant

    Almost solved: http://jsfiddle.net/tovic/kw7LD/22/

    function insert() {
    $('#container').html('');
    $('#container iframe').one("load", function() {
    $(this).attr('src', 'something.html');
    });
    }
    #106924
    Taufik Nurrohman
    Participant

    @elneco: Ehm… still triggering the loading spinner :p

    #120357
    Taufik Nurrohman
    Participant

    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);
    }

    http://jsfiddle.net/kw7LD/88/

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.