How to Refresh Web Pages Automatically

How to Refresh Web Pages Automatically thumbnail
Refresh Web Pages Automatically

If you have a website that frequently updates its contents over short periods of times, such as for news updates or changing sports scores, you may want your site to automatically refresh itself at set intervals. With a few lines of HTML or Javascript code you can easily add that sort of functionality to your website.

Instructions

  1. HTML Method

    • 1

      Open the text file that you are using to edit the HTML code of your web page or navigate to the file manager of your web host and click on the link to edit your website.

    • 2

      Find the opening and closing <HEAD> tag at the top of the page. Type in the "Meta HTTP-EQUIV" tag anywhere in the <HEAD> area.

    • 3

      Add in the "Content" and "URL" attributes to specify how long to wait before refreshing and what the URL of the website is that needs to be reloaded. For example type in <Meta HTTP-EQUIV="Refresh" Content="15; URL=http://www.mywebpage.com"> if you want your website to refresh once every 15 seconds. Save the file to make the change permanent.

    Javascript Method

    • 4

      Open the HTML file for your website and locate the <HEAD> tag. Specify that you will be using a Javascript code by typing in <script language="Javascript"> underneath the <HEAD> tag. Type in the opening and closing "<!--" and "//-->" tags to let the website know where your Javscript code begins and ends.

    • 5

      Inside the Javascript tags type "var time = null" and "function move() {" on the next two lines. Add in a third line and specify the URL for the website that needs to be reloaded by typing "window.location = 'http://www.mywebpage.com.''

    • 6

      Finish the Javascrpt code by finding the HTML <BODY> tag and adding the "onload" attribute. Type in the number of milliseconds that the website should wait before refreshing such as "<BODY onload="timer=setTimeout('move()',50000"> to set the time at 50 seconds. Finish your changes by saving the HTML file.

Tips & Warnings

  • Many web browsers have the option to disable any Javascript code because of the potential security threat they can pose. Be sure to test your website from multiple web browsers to ensure that the refresh code is working properly.

Related Searches:

Resources

  • Photo Credit Web Design

Comments

You May Also Like

Related Ads

Featured