Assignment #3

Using one of the object.property statements from the location Object, write a JavaScript that creates a link to a page on your server (upload the HTML document to an online website.) For instance, from my geocities.ws website, JavaScript will write a link, using the location (www.geocities.ws) to the page, but I must type extra information if there's a need, to complete the URL (notice the a href=// and bcjello inside quotes):

HTML file: Displayed by browser:
<BODY>

<SCRIPT LANGUAGE="javascript">
document.write("<A HREF=//" + location.host+ "/bcjello>Click here to link to my home webpage</A>.")
</SCRIPT>

</BODY>

Remember, location property will return the location where this document is saved at. If the file is on the hard drive, the script will return that location, where this document is saved. For example, running off my computer, the value of location.host = file:///C:// but when I upload this same document to my Geocities website, the value of location.host = www.geocities.ws. Now, because I specified that /bcjello should be added to the location.host value, the link will not work from my computer because there is no such folder. But the link created on the Geocities website will work.

BackTable of ContentsNext