Web Design, Development & Marketing

Web Development Articles

JavaScript: Redirect to Specified Location or Page

This script will redirect your browser to the specified location:

<script type="text/javascript">
    window.location = "http://www.your-new-location.com/yourFolder";
</script>

The above code will be executed as soon as the page it appears on is loaded. To be able to call a JavaScript command whenever you need it you can include it within a function as shown below: 

<script type="text/javascript">
function redirectPage()
{
window.location = "http://www.your-new-location.com/yourFolder";
}
</script>

You can then call this function from a button as shown below. The following form should be included anywhere in the body of the html document it appears in.

<form>
<input type="button" value="Redirect" onclick="redirectPage()">
</form>

Subscribe to RSS Feed Bookmark and Share

Related Links

Related Articles / Posts

Javascript Essentials - Date Pickers (Calendars) (03/03/2008)

Javascript: Variations of the IF Statement (20/09/2006)

Javascript / CSS: Flashing Text - How to do it - Why NOT to do it (16/09/2006)

Code Editors (Syntax Highlighting) - Aptana, Crimson Editor, PHP Designer (14/08/2006)

Web Dev News: Pro Ajax and PHP - Building Highly Interactive Applications (Book) (18/07/2006)