A couple of questions:

  • I've never really used JS listeners other than onclick and onkey events, so I wondered if someone could help me with what I need in order to reload the page every X seconds?

  • Secondly, the page contains bare minimum, literally just one input box. Do I still need to include the html head and body?

2

4 Answers

You don't need Javascript for this simple function. Add in the page header:

<meta http-equiv="Refresh" content="300"> 

300 is the number of seconds in this example.

1

To reload the page after 5 seconds (5000 milliseconds) using JavaScript, add the following to the bottom of the page:

<script type="text/javascript"> setTimeout(function () { location.reload(true); }, 5000); </script> 

As Greg Hewgill notes, you can also accomplish this with the meta refresh tag:

<meta http-equiv="Refresh" content="5"> 

Strictly speaking, you do still need <html> and <body> tags. Some browsers may render the page correctly without them, but your are safest to include them.

3

use a timer: and usee ajax to reload if it is dynamic

To your second question, ye you definitely do!!

Toy your first question check this out:

Or this to do it without javascript:

It does what you asked and is very easy to configure!

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy