Приглашаем посетить
Сладков (sladkov.lit-info.ru)

The Wide World of JavaScript

Previous Page
Table of Contents
Next Page

The Wide World of JavaScript

You've learned enough in this hour to have a head start on JavaScript and to add some snazzy interaction to your web pages. You've probably also gotten the idea that there's a lot more you can do, and it isn't as hard as you may have thought.

You may also find some scripts online that can be incorporated into a web page of your own with little or no modification. (Check out the JavaScript-related links in the files located at http://www.samspublishing.com/ for good places to find scripts.)

When you find scripts you'd like to reuse or experiment with, pay attention to the placement of the JavaScript code; generally, functions go in the <head> area, preceded by <script type="text/javascript"> and followed by </script>. The parts of the script that actually carry out the actions when the page is loaded go in the <body> part of the page, but still need to be set aside with the <script> tag. Sections of script that respond to specific events such as mouse moves go in the <a> or <input> tags, with special event attributes such as onmouseover.

You can also put JavaScript code into a separate file (usually with a .js file extension) by putting the name of the file in a src attribute within the <script /> tag, like the following:

<script type="text/javascript" src="bingo.js" />

This is especially handy when you are using a script that someone else wrote and you don't want it cluttering up your HTML.


Previous Page
Table of Contents
Next Page