Tuesday, 26 July 2016

How to redirect to another website in html


What is redirection? redirection means when a user enters your webpage url but it goes to other website with different url.
Sometimes you may require to redirect your web page to other page. For example sometimes you may require to make your website temporarily unavailable/offline for your users or sometimes you have build a new website with different url and you want your users to be presented with your new website rather than the old one. This can be possible in simple html using meta tag.
Meta Tag :- First we should know what is meta data. Meta Data is information about data. Meta tag provides information about our html document or webpage.

Meta tags are defined inside head tag <head> meta tags </head>

We can redirect using meta tag as given below:
<meta http-equiv="refresh" content="0; URL='http://www.mynewwebpage.com'" />

http-equiv :- it defines header of html document and this is sent to your browser at first priority before rest of the page. It is just like introducing yourself to some person. Your webpage introduce to the browser. 

url :- url contains the new address where you want your page to be redirected.

content :- content has the number of seconds after the url you specified should be loaded.

If you just wish to refresh your webpage after come seconds you can achieve this using

<meta http-equiv="refresh" content="10" />

the above code will refresh your webpage after every 10 seconds

No comments:

Post a Comment