Auto refresh code in HTML using meta tags
In HTML, we can refresh the page after some time duration. we will not use JavaScript. HTML provides this features.
HTML provide some tag attributes which provides some features.
1. We can refresh the page.
2. We can redirect the any URL
How to Use
We can use
"<meta>"
tag attributes "http-equiv"
in head tag section.The
"http-equiv"
attribute provides an HTTP header for the information/value of the content attribute. It can be used to simulate an HTTP response header.Syntax:
<meta http-equiv="content-security-policy|content-type|default-style|refresh">
Example 1
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="refresh" content="3">
<title>Example of Refresh Page </title>
</head>
<body>
<h1>Hello World!</h1>
<meta http-equiv="refresh" content="3">
<p><mark>Note: Change any text and save it, don't Refresh tag page, it will aromatically refresh</mark></p>
</body>
</html>
Here http-equiv="refresh" is used to refresh and content="3" is time duration.
Example 2
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="refresh" content="4; URL= https://www.google.com/">
<title>Example of Redirect </title>
</head>
<body>
<h1>Hello World!</h1>
<meta http-equiv="refresh" content="5;URL= https://www.google.com/">
<p><mark>Note: After 5 Second It will redirect to Google.com </mark></p>
</body>
</html>
Here content="5;URL= https://www.google.com/" is used to redirect to google.com.
Ref: https://www.w3schools.com/tags/att_meta_http_equiv.asp
Latest Post
Upload Image in MySQL database using Node js and React js
How to add new column to existing table without losing data in Laravel
Laravel Eloquent display query log in php
What is traits in PHP with example
How to disable click outside modal to close modal in bootstrap
Auto refresh code in HTML using meta tags
How to Optimize the Speed & Performance of a Laravel Website