refresh just the iframe every 5 seconds

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Donald Rogers

    refresh just the iframe every 5 seconds

    I'm new to Java so I just downloaded this code from dynamicdrive.co m and hope to make it work.
    I want it to refresh every 5 seconds. Any ideas?

    Code:
    <script language="JavaScript1.2">
    
    //Random iframe content- © Dynamic Drive (www.dynamicdrive.com)
    //For full source code, and Terms Of use, visit http://dynamicdrive.com
    //This credit MUST stay intact for use
    
    var ie=document.all&&navigator.userAgent.indexOf("Opera")==-1
    var dom=document.getElementById&&navigator.userAgent.indexOf("Opera")==-1
    
    //Specify IFRAME display attributes
    var iframeprops='width=364 height=241 marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" allowtransparency="true"'
    
    //Specify random URLs to display inside iframe
    var randomcontent=new Array()
    randomcontent[0]="http://fake.com/widgets/fake1"
    randomcontent[1]="http://fake.com/widgets/fake2"
    randomcontent[2]="http://fake.com/widgets/fake3"
    randomcontent[3]="http://fake.com/widgets/fake4"
    randomcontent[4]="http://fake.com/widgets/fake5"
    randomcontent[5]="http://fake.com/widgets/fake6"
    randomcontent[6]="http://fake.com/widgets/fake7"
    randomcontent[7]="http://fake.com/widgets/fake8"
    randomcontent[8]="http://fake.com/widgets/fake9"
    
    //No need to edit after here
    if (ie||dom)
    document.write('<iframe id="dynstuff" src="" '+iframeprops+'></iframe>')
    
    function random_iframe(){
    if (ie||dom){
    var iframeobj=document.getElementById? document.getElementById("dynstuff") : document.all.dynstuff
    iframeobj.src=randomcontent[Math.floor(Math.random()*randomcontent.length)]
    }
    }
    window.onload=random_iframe
    </script>
  • Frakes

    #2
    Is it possible to use a value passed in a url for a switch statement?

    I'm using HTML and Javascript to develop a home page and a search page. I'm passing values in the hyperlinks that connect the search page to the home page. I want to be able to hide/write text boxes on the search page depending on what link is clicked. (If they clicked the Region search link in the home page only the region text box is displayed on the search page, student search link only displays the student search box etc.) I'm reasonably sure this can be done but I guess something is missing because nothing shows up in my search page even though I have the value passed in the hyperlink displayed.

    Home Page:

    Code:
    <BODY>                                     
    <FORM NAME="HOMEPAGE" ID="HOMEPAGE" METHOD="POST"> 
    <TABLE>
    SEARCH FOR A CIR:</B> <BR />                             
    <A HREF="HTTPS://DEVL.DSS.STATE.MO.US/YCRS?TYPE=REGION"> 
    <LI> SEARCH BY REGION </LI>                              
    <A HREF="HTTPS://DEVL.DSS.STATE.MO.US/YCRS?TYPE=SUBMIT"> 
    <LI> SEARCH BY SUBMITTER</LI>                            
    <A HREF="HTTPS://DEVL.DSS.STATE.MO.US/YCRS?TYPE=STUDENT">
    <LI> SEARCH BY STUDENT ID</LI>                           
    <A HREF="HTTPS://DEVL.DSS.STATE.MO.US/YCRS?TYPE=DATE">   
    <LI> SEARCH BY DATE</LI> <BR/>   
    </TABLE>
    </BODY>
    SEARCH PAGE:

    Code:
    <HEAD>
    function getparams(){                                                   
     var idx=document.URL.indexOf('?');                                     
     var params = new Array();                                              
       if (idx != -1) {                                                     
    var pairs=document.URL.substring(idx+1, document.URL.length).split('&');
        for (var i=0; i<pairs.length; i++)  {                               
        nameVal = pairs[i].split('=');                                      
        params[nameVal[0]] = nameVal[1];                                    
     }
    }                                                            return params;                                                     }                                                            params = getparams();                                                
    </HEAD>
    
    <BODY>
    <form name="searchfunction" id="searchfunction" method="get">
    
    <input type=hidden name="srchTYPE" id="srchTYPE">               
    
    <script type="text/javascript">                                  
    var search = searchfunction.srchTYPE.value                       
    switch(search)                                                   
    {                                                          Case REGION:                                                   
    document.write('<tableborder="0"width="100%">');               
    document.write('<tr>');                                          
    document.write
    ('<td width="10%"><strong>REGION:</strong><br />');
    ETC ETC.
    break;
    
    
     case SUBMIT:                                                         
    document.write('<table border="0" width="100%">');                     
    document.write('<tr>');                                                
    document.write('<td width="10%"><strong>SUBMITTER ID:</strong><br />');
    ETC. ETC.
    break;
    }
    </script>
    </form>
    
    <script language="JavaScript">                     
        stype = unescape(params["TYPE"]);              
        document.searchfunction.srchTYPE.value = stype;
    </script>    
    </body>

    Comment

    • Dheeraj Joshi
      Recognized Expert Top Contributor
      • Jul 2009
      • 1129

      #3
      Probably you should post this is Java Script forum.
      Java != Java Script.

      Regards
      Dheeraj Joshi

      Comment

      • TITTLE

        #4
        If you want to refresh IFrame after certain time, why dont you use <meta refresh> in the file which is url of iframe. Syntax of <meta refresh> you can find in the google.

        Comment

        Working...