SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need a quick script

    I dont know JavaScript, but i need a script that auto-refresh a iframe, every 10 seconds.

    Can you get me one script?

    Thanks!



    Btw: The frame opens a random link each time its refreshed, but i think this random part i can do by myself.

  2. #2
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The <meta header> doesnt work well here because if the page doesnt load, it stops!

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The code must not wait for the page to load completly, if after 10 seconds the page is still loading, still refresh.

    Thanks.

  4. #4
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    here you are a javascript example

    Code:
    <html>
    
    <head>
    <title>Refresh JavaScript Example</title>
    <noscript>
    <!--
        We have the "refresh" meta-tag in case the user's browser does
        not correctly support JavaScript or has JavaScript disabled.
    
        Notice that this is nested within a "noscript" block.
    -->
    <meta http-equiv="refresh" content="2">
    
    </noscript>
    
    <script language="JavaScript">
    <!--
    
    var sURL = unescape(window.location.pathname);
    
    function doLoad()
    {
        // the timeout value should be the same as in the "refresh" meta-tag
        setTimeout( "refresh()", 2*1000 );
    }
    
    function refresh()
    {
        //  This version of the refresh function will cause a new
        //  entry in the visitor's history.  It is provided for
        //  those browsers that only support JavaScript 1.0.
        //
        window.location.href = sURL;
    }
    //-->
    </script>
    
    <script language="JavaScript1.1">
    <!--
    function refresh()
    {
        //  This version does NOT cause an entry in the browser's
        //  page view history.  Most browsers will always retrieve
        //  the document from the web-server whether it is already
        //  in the browsers page-cache or not.
        //  
        window.location.replace( sURL );
    }
    //-->
    </script>
    
    <script language="JavaScript1.2">
    <!--
    function refresh()
    {
        //  This version of the refresh function will be invoked
        //  for browsers that support JavaScript version 1.2
        //
        
        //  The argument to the location.reload function determines
        //  if the browser should retrieve the document from the
        //  web-server.  In our example all we need to do is cause
        //  the JavaScript block in the document body to be
        //  re-evaluated.  If we needed to pull the document from
        //  the web-server again (such as where the document contents
        //  change dynamically) we would pass the argument as 'true'.
        //  
        window.location.reload( false );
    }
    //-->
    </script>
    </head>
    
    <!--
        Use the "onload" event to start the refresh process.
    -->
    <body onload="doLoad()">
    
    <script language="JavaScript">
    <!--
        // we put this here so we can see something change
        document.write('<b>' + (new Date).toLocaleString() + '</b>');
    //-->
    </script>
    
    
    </body>
    
    </html>
    put it in the iframed page you want to refresh ...

  5. #5
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by free_dragon View Post
    here you are a javascript example

    Code:
    <html>
    
    <head>
    <title>Refresh JavaScript Example</title>
    <noscript>
    <!--
        We have the "refresh" meta-tag in case the user's browser does
        not correctly support JavaScript or has JavaScript disabled.
    
        Notice that this is nested within a "noscript" block.
    -->
    <meta http-equiv="refresh" content="2">
    
    </noscript>
    
    <script language="JavaScript">
    <!--
    
    var sURL = unescape(window.location.pathname);
    
    function doLoad()
    {
        // the timeout value should be the same as in the "refresh" meta-tag
        setTimeout( "refresh()", 2*1000 );
    }
    
    function refresh()
    {
        //  This version of the refresh function will cause a new
        //  entry in the visitor's history.  It is provided for
        //  those browsers that only support JavaScript 1.0.
        //
        window.location.href = sURL;
    }
    //-->
    </script>
    
    <script language="JavaScript1.1">
    <!--
    function refresh()
    {
        //  This version does NOT cause an entry in the browser's
        //  page view history.  Most browsers will always retrieve
        //  the document from the web-server whether it is already
        //  in the browsers page-cache or not.
        //  
        window.location.replace( sURL );
    }
    //-->
    </script>
    
    <script language="JavaScript1.2">
    <!--
    function refresh()
    {
        //  This version of the refresh function will be invoked
        //  for browsers that support JavaScript version 1.2
        //
        
        //  The argument to the location.reload function determines
        //  if the browser should retrieve the document from the
        //  web-server.  In our example all we need to do is cause
        //  the JavaScript block in the document body to be
        //  re-evaluated.  If we needed to pull the document from
        //  the web-server again (such as where the document contents
        //  change dynamically) we would pass the argument as 'true'.
        //  
        window.location.reload( false );
    }
    //-->
    </script>
    </head>
    
    <!--
        Use the "onload" event to start the refresh process.
    -->
    <body onload="doLoad()">
    
    <script language="JavaScript">
    <!--
        // we put this here so we can see something change
        document.write('<b>' + (new Date).toLocaleString() + '</b>');
    //-->
    </script>
    
    
    </body>
    
    </html>
    put it in the iframed page you want to refresh ...

    This script only refreshes after the page is fully loaded.
    And PHP can't change frame's page dunno why.

    But thanks anyway


    The code i wish is something like this one:
    http://www.autosurf.org/view.php?user=test

    Not for the same purposes, but it works very well.
    It has 2 frames, the one where the page reloads and the one that controls the reloading script.

    If you see, not all pages finish theyr downloads before the time runs out.

    I cant get this code out of the page, can you?

  6. #6
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, i could made it!
    Thanks!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •