Latest Tutorials| Questions and Answers|Ask Questions?|Site Map

Home Javascript Javascriptexamples JavaScript navigate to page

Related Tutorials


Share on Google+Share on Google+

JavaScript navigate to page

This page discusses - JavaScript navigate to page

JavaScript navigate to page


In this section, you will learn how to navigate from one page to another using JavaScript. For this purpose, we have created two html pages navigatePage.html and page.html. Here we are going to navigate from navigatePage.html to page.html. In navigatePage.html, we have created a button and used the href property of the location object with the onClick event which allows this page to navigate to page.html where we have created a simple form.

Here is the code of navigatePage.html:

<h2>Navigate Page</h2>
<input type="button" value="go to next page"
onclick="location.href='page.html' ">

Here is the code of page.html:

function valid(){
if ( == ""){
alert ( "Please enter Name." );
return false;
if (document.form.address.value == ""){
alert ( "Please enter Address." );
return false;
alert("Thanks for filling the form.");
return true;
<form name="form" method="post" onSubmit="valid();">
<tr><td>Enter Name:</td><td><input type="text" name="name"></td></tr>
<tr><td>Enter Address:</td><td><input type="text" name="address"></td></tr>
<tr><td><input type="submit" value="Submit"></td></tr>

Output will be displayed as:

On clicking the button, you will navigate to next page:

Download Source Code:



If you enjoyed this post then why not add us on Google+? Add us to your Circles

Liked it!  Share this Tutorial

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 18, 2011

Related Tutorials

Discuss: JavaScript navigate to page  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
June 21, 2012
Navigating Page helped me a lot:)