Javascript Navigation Tutorial

Javascript Navigation Tutorial thumbnail
Use Javascript to navigate URL locations.

Javascript allows programmers to navigate to other web pages using client-side code. This is beneficial when you want to dynamically send users to other pages after they click a link. Javascript has an "href" property, which sets the location of the user's web browser. The browser automatically navigates to the new location when the href property is set. The Javascript process is invisible to the user, and it can be used in place of HTML.

Instructions

    • 1

      Open your web page. Javascript is created in plain text code, so you can use any plain text editor such as Notepad. You can also use more advanced editors such as Notepad++ or Visual Studio, which color code the Javascript code.

    • 2

      Place the Javascript navigation function in your web page. All Javascript functions are placed within "<script>" tags. Place the following code within your "<head>" tags at the top of your web page code:
      <script type="text/javascript">
      function javaNavigation(url)
      {
      window.location.href = url
      }
      </script>

    • 3

      Place the function call in your hyperlinks. You can use the "javaNavigation" function in any link in your web page. To call the function and navigate to another website location, use the following code:
      <a href="#" onClick="javaNavigation('myPage.htm')">Click here</a>
      Replace "myPage.htm" with the name of the web page to which you want the browser to navigate.

    • 4

      Save the file and open it with your web browser. When you hover the mouse over the link, no destination URL is shown. However, when you click the link, the browser navigates to the URL processes by the Javascript function.

Related Searches:

References

  • Photo Credit http, www, icon, web, website image by creative from Fotolia.com

Comments

You May Also Like

Related Ads

Featured