iframe loading

Discussion in 'JavaScript' started by jonhyhar, Jan 19, 2010.

  1. #1
    hey guys, how can we show loading.gif while the iframe is loading?
     
    jonhyhar, Jan 19, 2010 IP
  2. s_ruben

    s_ruben Active Member

    Messages:
    735
    Likes Received:
    26
    Best Answers:
    1
    Trophy Points:
    78
    #2
    I think this script will help you

    
    <html>
    
    <head>
      <title>Loading iframe</title>
    </head>
    
    <script>
    function loading_iframe(){
        document.getElementById('loading_iframe').style.display = "none";
        document.getElementById('loading').style.display = "";
        document.getElementById('loading_iframe').onload = function(){
            document.getElementById('loading').style.display = "none";
            document.getElementById('loading_iframe').style.display = "";
        }
    }
    </script>
    
    <body>
    <iframe id="loading_iframe" src="http://rubensargsyan.com/" width="800" height="600"></iframe>
    <div id="loading">Loading...</div>
    
    </body>
    
    <script>
    loading_iframe();
    </script>
    
    </html>
    
    Code (markup):
     
    s_ruben, Jan 19, 2010 IP
  3. jonhyhar

    jonhyhar Active Member

    Messages:
    166
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    but it doesn't work in mootools iframe popup :(
     
    jonhyhar, Jan 19, 2010 IP
  4. s_ruben

    s_ruben Active Member

    Messages:
    735
    Likes Received:
    26
    Best Answers:
    1
    Trophy Points:
    78
    #4
    What do you mean? I don't know what is "mootools iframe popup". :(
     
    s_ruben, Jan 19, 2010 IP
  5. jonhyhar

    jonhyhar Active Member

    Messages:
    166
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #5
    here it's my popup code

    $("CTB_window").innerHTML+="<div id='CTB_title'><div id='CTB_ajaxWindowTitle'>"+j+"</div><div id='CTB_closeAjaxWindow'></div></div><iframe frameborder='0' hspe='0' src='"+urlNoQuery[0]+"&in_smoothbox=true' id='CTB_iframeContent' name='CTB_iframeContent' scrolling='no' style='width:"+(d+29)+"px;height:"+(i+17)+"px;'> </iframe><div class='popupalt'><a href='#' id='CTB_closeWindowButton' title='Close'><img src='http://s.ytimg.com/yt/img/pixel-vfl73.gif' width=1 height=1 border=0  onload='CTB_showWindow()'></a></div>"
    Code (markup):
    All i want is to show loading.gif while the iframe is loading :(
     
    jonhyhar, Jan 19, 2010 IP