shadowline
TimeOut << Location >> Windows
One of the most used instances of JavaScript is location. Location represents the URL or web page address. Location can be used to determine the current URL and also to change the URL to a different page or site.

The location of this page is :

The location of this page is :
<script type="text/javascript">
<!--
document.write(location.href);
// -->
</script>

The above script showed how to "see" the current window URL. Now what about changing that URL to a new location? Using a simple form button, the visitor can be linked over to a new page or site.

<center>
<form>
<input type="button" VALUE="Visit Microsoft" OnClick="location.href='http://www.microsoft.com/';">
</form>
</center>

A couple things should be noticed in the above coding.
  • The use of single quotes around the URL. This is so the coding is not confused with the surrounding double quotes of the OnClick command.
  • The semi-colon after the URL. As with most JavaScript commands, this too is ended with a semi-colon to show it's ending.
One great thing about this is the available use of a button instead of an image for navigation. Many people like the button visually over an image. It creates a sort of "depressed" effect as the visitor clicks on it.
TimeOut << Location >> Windows
shadow

Advertise in the banner along the top, Click here!

Valid XHTML 1.0 Transitional Valid CSS! Text Link Ads
shadow
shadow