Implementation of automatic page refresh

Source: Internet
Author: User

Sometimes use the whole page automatically refresh, in the front end can be implemented in two ways, the first is the use of META tags to send HTTP headers for automatic refresh, the second is the use of JavaScript function delay for automatic refresh.

1. Using Meta tags to automate page refreshes

Meta tags can have a lot of features, location is placed in the HTML code

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

http-equiv= "Refresh" function is to tell the browser to automatically refresh the page or redirect to a new URL

2, using JavaScript to achieve automatic page refresh

JavaScript in the window.location has a method of refreshing the page reload (), the method is encapsulated into a function, and then delay execution can be, refresh the page and then execute, so that the implementation of automatic refresh

1 <Scripttype= "Text/javascript">2     functionMyrefresh () {3 window.location.reload ();4     }5 SetTimeout ('Myrefresh ()', the); //5s after performing function Refresh page6 </Script>

This will automatically refresh the page

Implementation of automatic page refresh

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.