Copy Code code as follows:
//---------------------------------------------------------------
Opacity Displayer, Version 1.0
Copyright Michael Lovitt, 6/2002.
Distribute freely, but please leave this notice intact.
//---------------------------------------------------------------
//---------------------------------------------------------------
OPACITY OBJECT
//
Instantiates the object, defines the properties and methods.
function Opacityobject (Div, strpath) {
This.layerobject = div;
This.path = strpath;
/* IF (NS) {
if (browserversion>=5) {
This.layerobject = document.getElementById (divid). style;
} else {
This.layerobject = eval ("document." +divid);
}
} else {
This.layerobject = eval (divID + ". Style");
}/**/
This.setbackground = Od_object_setbackground;
}
Uses AlphaImageLoader filter, or the CSS background property,
As appropriate, to apply a PNG or GIF as the background of the layerobject.
function Od_object_setbackground () {
if (Pngalpha) {
This.layerObject.filter = "Progid:DXImageTransform.Microsoft.AlphaImageLoader" (src= ' +this.path+ ". png '), sizingmethod= ' scale ') ";
else if (pngnormal) {
if (Browser.ismac && browser.isie5up) this.layerObject.backgroundColor = ' #999999 ';
else this.layerObject.backgroundImage = ' url (' +this.path+ '. png) ';
} else {
this.layerObject.backgroundImage = ' url (' +this.path+ '. gif) ';
}
}
//---------------------------------------------------------------
//---------------------------------------------------------------
OPACITY DISPLAY FUNCTION
Outputs the image as a div with the alphaimageloader, or with
A standard image tag.
function Od_displayimage (Strid, strpath, Intwidth, Intheight, strclass, Stralt) {
if (Pngalpha) {
document.write (' <div style= "Height: ' +intheight+ ' px;width: ' +intwidth+ ' px;filter:progid:d XImageTransform.Microsoft.AlphaImageLoader (src=\ ' +strpath+ '. png\ ', sizingmethod=\ ' scale\ ') "id=" ' +strid+ ' class = "' +strclass+ '" ></div> ");
else if (pngnormal) {
document.write (' } else {
document.write (' }
}
//---------------------------------------------------------------
//---------------------------------------------------------------
OPACITY Roll-over functions
function Od_rollover (Strid, Strcolor) {
if (Pngalpha) {
document.getElementById (Strid). Style.backgroundcolor = Strcolor;
} else {
if (document.images && (flag = = True)) {
DOCUMENT[STRID].SRC = eval (Strid + "on.src");
}
}
}
function Od_rollout (Strid, Strcolor) {
if (Pngalpha) {
document.getElementById (Strid). Style.backgroundcolor = Strcolor;
} else {
if (document.images) {
DOCUMENT[STRID].SRC = eval (Strid + "off.src");
}
}
}
//---------------------------------------------------------------
//---------------------------------------------------------------
Global variables
If ie5.5+ on Win32, then display PNGs with AlphaImageLoader
if ((Browser.isie55 | | browser.isie6up) && browser.iswin32) {
var pngalpha = true;
var strext = ". png";
else, if the browser can display PNGs normally, then do. That list includes:
-gecko Engine:netscape 6 or Mozilla, Mac or PC
-ie5+ Mac (Opacityobject applies the background image at 100% opacity)
-opera 6+ PC
-opera 5+ Mac (doesn ' t support dynamically-set background)
-opera 6+ Linux
-omniweb 3.1+
-icab 1.9+
-webtv
-sega Dreamcast
else if ((Browser.isgecko) | | (browser.isie5up && browser.ismac) | | (Browser.isopera && Browser.iswin && browser.versionmajor >= 6) | | (Browser.isopera && Browser.isunix && browser.versionmajor >= 6) | | (Browser.isopera && browser.ismac && browser.versionmajor >= 5) | | (Browser.isomniweb && browser.versionminor >= 3.1) | | (Browser.isicab && browser.versionminor >= 1.9) | | (BROWSER.ISWEBTV) | | (Browser.isdreamcast)) {
var pngnormal = true;
var strext = ". png";
Otherwise, we use the plain old GIFs
} else {
var strext = ". gif";
}
var ns = (document.all)? False:true;
var browserversion = parsefloat (navigator.appversion);
//---------------------------------------------------------------