![]() |
<html>
<head>
My first JavaScript!
</head>
<body>
<br>
This is a normal HTML document.
<br>
<script language = "Javascript">
document.write("This is JavaScript!")
</script>
<br>
Back in HTML again.
</body>
</html>
This is a normal HTML document
This is JavaScript!
Back in HTML again.
<html>
<head>
<script language = "Javascript">
<!-- to hide script contents from old browsers
function square(i){
document.write("The call passed", i, "to the function.","<BR>)
return i * i
}
document.write("The function returned", square(5), ".")
// end hiding contents from old browsers -->
</script>
</head>
<body>
<br>
All done.
</body>
</html>
The output would be:
The call passed 5 to the function. ** Note on the previous example that the script was placed in HTML comments
...that is Code Hiding. It is used to ensure that your JavaScript code is not
displayed by old browsers that do not recognize JavaScript.
On the horizon...
Sun and Netscape are currently working together so that the next release
of JavaScript will be capable of interacting with Java applets, allowing
several applets on one page to pool information and manipulate objects
within the page such as forms.
The function returned 25.
All done.
Useful applications of JavaScript
Also See
HelpNet was created by the 1995 incoming graduate class. It is only occasionally updated. Department of Computer Science
School of Engineering, University of Virginia
151 Engineer's Way, P.O. Box 400740
Charlottesville, Virginia 22904-4740
(434) 982-2200 Fax: (434) 982-2214 Web Comments: webteam@cs.virginia.edu
Admissions Inquiries: inquiry@cs.virginia.edu
Site directory, Other addresses
Server statistics
© Created by the CS Web Team