Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
39 views

Source Code For Script1.html: Listing 3-1

The document provides instructions for creating a basic JavaScript script to display the user's browser type on a web page. It outlines the following steps: 1. Open a text editor and create a new blank document. 2. Copy the code example exactly as shown, paying careful attention to syntax. 3. Save the file as script1.html. 4. Open the file in a web browser to preview the script.

Uploaded by

Karnataka567
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Source Code For Script1.html: Listing 3-1

The document provides instructions for creating a basic JavaScript script to display the user's browser type on a web page. It outlines the following steps: 1. Open a text editor and create a new blank document. 2. Copy the code example exactly as shown, paying careful attention to syntax. 3. Save the file as script1.html. 4. Open the file in a web browser to preview the script.

Uploaded by

Karnataka567
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

home page of the browsers publisherunless youve changed the settings) is unavailable. Thats fine.

You
want the browser open, but you dont need to be connected to your ISP. If youre automatically
connected to
the Internet through a local area network in your office or school or cable modem or DSL, thats also
fine.
However, you dont need the network connection for now. Next, follow these steps to enter and
preview
your first JavaScript script:
1. Activate your text editor and create a new, blank document.
2. Type the script in the window exactly as shown in Listing 3-1.
Follow the example slowly and carefully, paying special attention to:
a. The uppercase and lowercase letters
b. The placement of single () and double () quote symbols
c. The usage of parentheses, angle brackets (< and >), and curly braces ({ and })
LISTING 3-1

Source Code for script1.html

<html>
<head>
<title>My First Script</title>
<style type=text/css>
.highlight {color: red}
</style>
<script type=text/javascript>
function showBrowserType() {
document.getElementById(readout).innerHTML =
Your browser says it is: +
<span class=highlight> +
navigator.userAgent + </span>.<hr />;
}
window.onload = showBrowserType;
</script>
</head>
<body>
<h1>Lets Script...</h1>
<hr>
<h1>Lets Script...</h1>
<hr />
<div id=readout></div>
</body>
</html>
3. Save the document with the name script1.html.

4. Switch to your browser.


5. Choose Open (or Open File on some browsers) from the File menu, and select script1.html.
(On some browsers, you have to click a Browse button to reach the File dialog box.)

22

Part I

Getting Started with JavaScript

You might also like