Download the X Distribution File.
new xTriStateImage(idOut, urlOver, urlDown, fnUp)
Default.
// xTriStateImage r4, Copyright 2004-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL
function xTriStateImage(idOut, urlOver, urlDown, fnUp) // Object Prototype
{
var img;
// Downgrade Detection
if (typeof Image != 'undefined' && document.getElementById) {
img = document.getElementById(idOut);
if (img) {
// Constructor Code
var urlOut = img.src;
var i = new Image();
i.src = urlOver;
i = new Image();
i.src = urlDown;
// Event Listeners (closure)
img.onmouseover = function() { this.src = urlOver; };
img.onmouseout = function() { this.src = urlOut; };
img.onmousedown = function() { this.src = urlDown; };
img.onmouseup = function()
{
this.src = urlOver;
if (fnUp) {
fnUp();
}
};
}
}
// Destructor Method
this.onunload = function()
{
if (!window.opera && img) { // Remove any circular references for IE
img.onmouseover = img.onmouseout = img.onmousedown = null;
img = null;
}
};
}
xtristateimage - 3 state image rollovers
By your use of X and/or CBE and/or any Javascript from this site you consent to the GNU LGPL - please read it. If you have any questions about the license, read the FAQ and/or come to the forums.
Forum support is available at the X Library Support Forums.
Cross-Browser.com is the home of X - a cross-browser Javascript library, and many demos, applications, articles and documentation.
If you are using X, XC or anything from this site, show off your work by posting a link in the X Showcase forum.