www.webdeveloper.com
Results 1 to 5 of 5

Thread: How can i repeat a Javascript all 10 Seconds ?

  1. #1
    Join Date
    Sep 2013
    Posts
    2

    Question How can i repeat a Javascript all 10 Seconds ?

    Help me !

    Here the Code :
    HTML Code:
    <script type="text/javascript">
    var jetzt = new Date();
    var Std = jetzt.getHours();
    if (Std >= 6 && Std < 23) {
     window.location.reload()
    
    }
    </script>
    How can i repeat the Code without reloading the Page ?

    I have no idea about JavaScript

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    Code:
    <script type="text/javascript">
    function func(){
    var jetzt = new Date();
    var Std = jetzt.getHours();
    if (Std >= 6 && Std < 23) {
    window.location.reload();
    }
    }
    
    setTimeout('func()',10000); // time in milliseconds
    </script>
    http://www.w3schools.com/jsref/met_win_settimeout.asp
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  3. #3
    Join Date
    Sep 2013
    Posts
    2
    Now the Script doesnt work D:

  4. #4
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,265
    The script run, but the change is not visible... Try this with 1 second !
    HTML Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="generator" content="PSPad editor, www.pspad.com">
    <title></title>
    <style type="text/css">
    
    </style>
    </head>
    <body>
    <p id="rsp">Guten tag !</p>
    <script type="text/javascript">
    
    var jetzt = new Date();  
    var Std = jetzt.getHours();
    document.getElementById('rsp').innerHTML=jetzt.toLocaleString();
    if (6 <= Std && Std < 23) setTimeout(function(){window.location.reload()},1000);
    
    </script>
    </body>
    </html>
    Last edited by 007Julien; 09-23-2013 at 10:05 AM.

  5. #5
    Join Date
    Sep 2013
    Posts
    221
    Try out this one.
    You can use SetTimeout .

    The syntax is:
    var timerId = setTimeout(func|code, delay)

    Hope this helps you.
    Thnxs.
    strad solutionswww.stradsolutions.com

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles