Intermediate Web Publishing

JavaScript statements and expressions

A standard C++-like programming language

Exercise: Start NOTEPAD, and write a simple HTML program that checks for the type of browser, and creates different web pages depending on whether or not it's Netscape.

Sample solution

<script language="javascript">
<!--
if (navigator.appName.substring(0,8) == "Netscape") {
   document.write("<h1>Netscape!</h1>")
} else {
   document.write("<h1>Is this MSIE?</h1>")
}
// --></SCRIPT>
<noscript>
<h1>Some Old browser</h1>
</noscript>
 . . .
[up] [next]JavaScript variables