The JavaScript language, working in tandem with related browser features, is a Web-enhancing technology. When employed on the client computer, the language can help turn a static page of content into an engaging, interactive, and intelligent experience. Applications can be as subtle as welcoming a site’s visitor with the greeting “Good morning!” when it is morning in the client computer’s time zone—even though it is dinnertime where the server is located. Or applications
can be much more obvious, such as delivering the content of a slide show in a one-page download while JavaScript controls the sequence of hiding, showing, and “flying slide” transitions while navigating through the presentation.
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 into the window exactly as shown.
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.)
<html>
<head>
<title>My First Script</title>
<style type=”text/css”>
.highlight {font-weight: bold}
</style>
</head>
<body>
<h1>Let’s Script...</h1>
<hr>
<script type=”text/javascript”>
<!-- hide from old browsers
document.write(“This browser is version “ + navigator.appVersion);
document.write(“of <span class=’highlight’>” + navigator.appName + “</span>.”);
// end script hiding -->
</script>
</body>
</html>
0 comments:
Post a Comment