欢迎来到福编程网,本站提供各种互联网专业知识!

Opacity.js

发布时间:2007-01-22 作者: 来源:转载
复制代码代码如下://---------------------------------------------------------------//OpacityDisplayer,Version1.0//CopyrightMichaelLovitt,6/2002.//Distributefreely,butpleaseleavethisnoticeintact.//---------------------------------------------

复制代码 代码如下:
//---------------------------------------------------------------
//OpacityDisplayer,Version1.0
//CopyrightMichaelLovitt,6/2002.
//Distributefreely,butpleaseleavethisnoticeintact.
//---------------------------------------------------------------

//---------------------------------------------------------------
//OPACITYOBJECT
//
//Instantiatestheobject,definesthepropertiesandmethods.

functionOpacityObject(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;
}
//UsesAlphaImageLoaderfilter,orthecssbackgroundproperty,
//asappropriate,toapplyaPNGorGIFasthebackgroundofthelayerObject.
functionod_object_setBackground(){
if(pngAlpha){
this.layerObject.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.path+".png',sizingMethod='scale')";
}elseif(pngNormal){
if(browser.isMac&&browser.isIE5up)this.layerObject.backgroundColor='#999999';
elsethis.layerObject.backgroundImage='url('+this.path+'.png)';
}else{
this.layerObject.backgroundImage='url('+this.path+'.gif)';
}
}
//---------------------------------------------------------------

//---------------------------------------------------------------
//OPACITYDISPLAYFUNCTION
//OutputstheimageasadivwiththeAlphaImageLoader,orwith
//astandardimagetag.
functionod_displayImage(strId,strPath,intWidth,intHeight,strClass,strAlt){
if(pngAlpha){
document.write('

');
}elseif(pngNormal){
document.write('');
}else{
document.write('');
}
}
//---------------------------------------------------------------

//---------------------------------------------------------------
//OPACITYROLL-OVERFUNCTIONS
functionod_rollOver(strId,strColor){
if(pngAlpha){
document.getElementById(strId).style.backgroundColor=strColor;
}else{
if(document.images&&(flag==true)){
document[strId].src=eval(strId+"on.src");
}
}
}
functionod_rollOut(strId,strColor){
if(pngAlpha){
document.getElementById(strId).style.backgroundColor=strColor;
}else{
if(document.images){
document[strId].src=eval(strId+"off.src");
}
}
}
//---------------------------------------------------------------

//---------------------------------------------------------------
//globalvariables

//ifIE5.5+onwin32,thendisplayPNGswithAlphaImageLoader
if((browser.isIE55||browser.isIE6up)&&browser.isWin32){
varpngAlpha=true;
varstrExt=".png";
//else,ifthebrowsercandisplayPNGsnormally,thendothat.thatlistincludes:
//-GeckoEngine:Netscape6orMozilla,MacorPC
//-IE5+Mac(OpacityObjectappliesthebackgroundimageat100%opacity)
//-Opera6+PC
//-Opera5+Mac(Doesn'tsupportdynamically-setbackgroundimages)
//-Opera6+Linux
//-Omniweb3.1+
//-Icab1.9+
//-WebTV
//-SegaDreamcast
}elseif((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)){
varpngNormal=true;
varstrExt=".png";
//otherwise,weuseplainoldGIFs
}else{
varstrExt=".gif";
}

varns=(document.all)?false:true;
varbrowserVersion=parseFloat(navigator.appVersion);
//---------------------------------------------------------------

相关推荐