Do you sell items available in different colors?
OR do you want to play with image colors from a simple
JavaScripts?
If yes, this applet is right for you !
How this works
One
can specify unlimited number of image layers for the applet. Applet overlays
them and draws the resulting image. Image listed first will be drawn first.
Using transparent images allows to create very complex image. Below
is an example with only two layers IMAGE0 and IMAGE1.
<APPLET NAME="vmaxcolorizer" CODE=vmaxcolorizer.class WIDTH=504 HEIGHT=247> <PARAM NAME="IMAGE0" VALUE="986a.gif"> <PARAM NAME="IMAGE1" VALUE="986b.gif"> <PARAM NAME="AUTHOR" VALUE="Virtual_Max (http://come.to/vmax)"> <PARAM NAME="KEY" VALUE="Free Version"> </APPLET>One can define as much layers as needed with "IMAGEi" param, the only limitation is that images enumerations starts with 0 and have no missed numbers.
The rest is done with
calling of applet public methods from simple JavaScript. Here is
basic JavaScript code from this page source
Before calling of applet colorize
method one should test the browser allows to do this. Most of browsers
can do this (Netscape 3 or higher and Microsoft Explorer 4 or better).
But to avoid JavaScript errors one should check the browser version and
vendor and check navigator.javaEnabled().
| aname=navigator.appName;
aver =navigator.appVersion; var brOK=false; if( ((aname.indexOf("Netscape")!=-1)&&(parseInt(aver)>=3)) ||((aname.indexOf("Explorer")!=-1)&&(parseInt(aver)>=4)) ) brOK=true; if(brOK){ if(navigator.JavaEnabled) if(!navigator.JavaEnabled()) brOK=false; else brOK=false; } |
| function setimagecolor(nimage,color){
if(brOK){ if(document.vmaxcolorizer!=null){ if(document.vmaxcolorizer.ready==true){ col=parseInt(color+""); document.vmaxcolorizer.colorize(nimage,col); } } } } |
| <FORM>
<SELECT onChange="setimagecolor(1,this.options[this.selectedIndex].value);"> <OPTION value="0xffffff"></B>Silver <OPTION value="0x80ffff">Cyan <OPTION value="0xffff80">Yellow <OPTION value="0xff0000">Red <OPTION value="0x008000">Green </SELECT> </FORM> |
Don't hesitate to look into this page HTML source for complete script.