Home Javascript Javascriptexamples JavaScript Navigate to URL
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

JavaScript Navigate to URL

Advertisement
This page discusses - JavaScript Navigate to URL

JavaScript Navigate to URL

        

JavaScript provides several methods and properties which allow the user to navigate to the various locations. Here we are using the 'href' property of location object for this purpose. This will navigate the user to the specified location. Then we have created a link "Click here to Navigate RoseIndia home page". On clicking the link, the method navigateToURL() is called which navigates to the specified URL "http://www.roseindia.net".

Here is the code:

<html>
<h2>Navigate to URL</h2>
<script>
function navigateToURL() {
window.location.href = "http://www.roseindia.net";
}
</script>
<a href="#" onclick="navigateToURL();">Click here to Navigate RoseIndia home page</a>
</html>

Output will be displayed as:

When you click the link, the specified url will get open:

Download Source Code:

 

        

Advertisement

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

Ask Questions?    Discuss: JavaScript Navigate to URL  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com