[an error occurred while processing this directive]

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:

 

                          

[an error occurred while processing this directive]