23 December 2010

how to use redirect using Javascript

javascript
Redirects are useful when doing some work and needs to go to another page after finished the work.

For example : after showing successful login , you will be redirected to home page.

Using button as link using javascript inside HTML code:

<input type="button" value="Visit Google" onclick="window.location = 'http://www.google.com' "/>

Use one line code to redirect :

 window.location = "http://www.google.com" ;


Note: The window.location object can be used to get the current page address (URL) and to redirect the browser to a new page.

(If you found this article useful then share with your friends.)

No comments: