background
|
|
News
All in one Place
All of your regular news in one place.
More icon

bonsai
The Element
A small area for Bonsai related material.
More icon
|
|
Up Image
Navigation
Search this Site
Enter your search terms

Site Breadcrumb - You are here
|
Reference   JavaScript Code Library

JavaScript is commonly used to change the source of an image (for example, when a user clicks on or mouses over the image in question). The WM_imageSwap() function takes a reference to the original image and a URL for the new image as arguments and then changes the source of the original image to that of the new image.

Usage: WM_imageSwap(originalImage, 'newSourceUrl');
originalImage can be either of the following:

  • A predefined name for the image ('foo', for example, if the image tag includes name="foo"). The name should be a string, so don't forget to enclose it in quotes.
  • An actual object reference (such as window.top.someFrame.myImage). Note, however, that this will produce an error in IE 3 for the Macintosh if you refer to the images array. To use object references without producing errors, use document.myImage in place of document.images['myImage'].

Example: <a href="#" onMouseOver="WM_imageSwap('myImg', 'on.gif');" onMouseOut="WM_imageSwap('myImg', 'off.gif');"><img name="myImg" src="off.gif"></a>

Requires: WM_preloadImages() (optional, but recommended)

Cut, paste, and enjoy!