--== Events ==--

[ Previous Section | Home | Index | Test Your HTML | Related links | Next Section ]



One advantage of Java Script is that it can respond to what a user does. It does this by using something called "events". Events occur when the user performs a certain action such as moving over a link, clicking a button, when the page loads, or when th e user leaves the page. When an event occurs you can write your script to run a function. For instance you can display a goodbye alert activated when the user leaves the page. You can also display a message in the status bar when the user moves his mous e over a link. The "status bar" is the bar at the bottom of the browser window. It allows you to include special text pertinent to the link. To run a function when the user moves their mouse over something you use the onMouseover="function" . Inside the quotes you put the function that you want to run. A sample script would look like what follows:

<HTML>
<Head>
</Head>

<Body>
<a href="index.html" onMouseOver="self.status='This is the link to the index.';return true;">
INDEX </Body>
</HTML>

INDEX

For this method we do not need the Script tags in the body. They are only needed to define the function. Try moving your mouse over the link and see what happens. The other events work in the same way. Include them in the relative tags to enhance your page.


Here is a list of other events:
onMouseOver="function" Event for mouse moving over something Used in link tags, buttons, and images
onClick="function" Event for when a user clicks on a link or button Used in link tags, and buttons
onLoad="function" Event for when the page loads Used in body tag
onunLoad="function" Event for when the page unloads Used in body tag



[ Previous Section | Home | Index | Test Your HTML | Related links | Next Section ]