Writing for the World Wide Web
Window Alert
Sometimes you want to inform your audiences of certain information before they enter your website. For example, if your page requires a certain browser (using the "System Detection" JavaScript), you could alert your audiences to this before your page loads with an alert window. Here are the lines of code; play around with them and see what you can do. There are different ways alert windows could be implemented into a page:

<script language="JavaScript">
window.alert("Your Browser: " + navigator.appName);
</script>

The above lines of code placed in the head of your document will generate the alert window you saw when this page loaded. Here is a basic breakdown of what each part means:

  • "Your Browser"—any actual text of your own that you want to appear in the the alert window should be placed in quotation marks
  • navigator.appName—anything that is a JavaScript function or variable should not be in quotation marks, but should just be in the parentheses
  • +—when you have more than one component (a text string, variable, etc.) that you want to be displayed, you join the components with a plus sign

You could also make links that alert users to information, as shown in the example below:

Click here for this page URL.

The above lines of code placed in the body of your document will allow users to click the link and get the URL information. Here is the code:

<p>Click here for <a href="#" onclick="window.alert('Current Page: ' + location.href); return false;">this page URL</a>.</p>


Home | Course Information | Assignments | Schedule | Class Notes | Resources | Student Pages