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:

Tutorials
- Java 26 (JDK 26) Features with examples
- Top 10 Reasons to Learn Java in 2026
- JDK 26 Tutorial
- Java Certification Roadmap 2026: Which Oracle Certs Matter
- Install JDK 26: A Complete Beginner's Guide (2026)
- What Is Java? A Complete, Up-to-Date Guide for 2026
- Java 26 HTTP3 tutorial - HTTP 3 support in JDK 26 - How to use HTTP/3 in Java 26 application?
- JDK 28 Preview: Value Objects, Shenandoah GC & JSON API
- Java Tutorials


