• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 4. Image Basics > Using a Function to Code Multiple Rollovers

Using a Function to Code Multiple Rollovers

Extending the example of the previous script, Script 4.8 shows how the same function can be called many times within the same statement. All you have to do is use a semicolon between commands.

Script 4.8. You can call a function as many times as you want, as long as you separate each call with a semicolon.


To use a function to simplify multiple rollovers

  • <a href="flyPage.html" onmouseover=
    → "chgImg('flyImg','flyOn');
    → chgImg('textField','flyText')"
    → onmouseout="chgImg('flyImg',
    → 'flyOff');chgImg('textField',
    → 'bgText')"><img src="images/
    → flyer.gif" width="293" height=
    → "165" border="0" vspace="20" name=v
    → "flyImg" alt="Flying Machine" /></a>
    

    Everything else in this script should be familiar by now, except calling the function chgImg four times, separated by semicolons. The function gets called twice for the onmouseover handler (to change the flying machine image from the regular to the drop-shadow version and to change the description text) and twice for the onmouseout handler (to reverse the process).

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint