March 26, 2013

Redirect after 5 seconds

This post shows the demonstration on how to redirect to another page after some seconds in application. There are two types of code is use. One using meta tag and other one is use JavaScript. 

Use this line within <head> section of page.

<meta http-equiv="refresh" content="N; URL=other-web-address">

Here: section of page.

  • Replace N with number. For Example 5, so page will be redirect after 5 seconds.
  • Set URL to where redirection occur
The modified code will be

<meta http-equiv="refresh" content="10; URL=">

If you are using Content page then instead of using above method use JavaScript code as

<script type="text/javascript">  


    function delayRedirect(url)
        var Timeout = setTimeout("window.location='" + url + "'",5000);

Hope you understand well. Let me know if anybody face any issue. Stay tuned.

1 comment: