2

I have following problem with my website. I created very simple website for my family (including my grandfather) but they don't know much about internet. That is why I have to create auto refresh when they open a website.

My website is here: http://kartingsiemianowice.pl/ (please don't look at the code, because it was created just for few days).

Can you let me know how can I create refresh when they open a website? Because when I will change something and send these files to FTP then they have to refresh page.

Captain Obvlious
  • 19,754
  • 5
  • 44
  • 74
user3097025
  • 153
  • 1
  • 4
  • 7

3 Answers3

4

Best HTML code placed in head section of the website works good in all browsers.

<head> <meta http-equiv="refresh" content="60"> </head> 

Where meta will say to browser what to do and content is time in seconds.

If you need to transfer your visitor to another domain just use:

<meta http-equiv="refresh" content="2;url=https://mlmos.com/">

where meta will say what to do, content time in seconds, now 2 or as you wish, then order to redirect to any url, in this case mlmos.com

Hope so this simple solution will help!

Igor B.
  • 71
  • 4
3

As Minh Quy stated in the comments, you can use the JS function setInterval or setTimeout

Example below :

setInterval(function(){alert("Hello")}, 3000);

setTimeout(function () {
    location.reload();
}, 3000);

The first simple example displays a pop-up alert window every 3 seconds and the second reloads the page after 3 seconds.

So for your purposes, you will need to use this function in conjunction with your existing code to refresh the page when the user visits a specific page or performs a specific action.

aphextwix
  • 1,838
  • 3
  • 21
  • 27
3

Use following code

setTimeout(function () {
    location.reload();
}, 1000);

where 1000 is the number of milliseconds to wait before executing the code.

Hayk Aghabekyan
  • 1,087
  • 10
  • 19
  • if you are wondering why not to use setInterval instead of setTimeout, read this http://stackoverflow.com/questions/729921/settimeout-or-setinterval – Hayk Aghabekyan Nov 27 '14 at 18:26