Tulos
Koodi
Tämä tulee HEAD-osastoon
<script type="text/javascript">
<!--
function maketable(n) {
var nb;
this.length = n;
for (var i = 1; i <=n; i++)
if (i<10) {
nb = i+"";
nb = nb.substring(0,1);
this[i] = nb;
}
return this;
}
function conversion(color) {
var hexa1;
var hexa2;
var colorHexa;
tabHex = new maketable(16);
tabHex[10]="A"; tabHex[11]="B"; tabHex[12]="C"; tabHex[13]="D"; tabHex[14]="E"; tabHex[15]="F";
hexa2 = (color%16);
hexa1 = parseInt(color/16);
hexa2 = tabHex[hexa2];
if (hexa2 == null)
hexa2 = "0";
hexa1 = tabHex[hexa1];
if (hexa1 == null)
hexa1 = "0";
colorHexa = hexa1 + hexa2;
return colorHexa;
}
function degrade(teksti, koko, tyyppi, RGB) {
var factor = 256/(teksti.length+1);
var i;
var c1,c2,c3;
for (i=0;i<teksti.length;i++) {
ton=factor*i;
if (RGB == 0) {
c1 = 'FF'
c2 = conversion(ton);
c3 = c2;
}
else if (RGB == 1) {
c1 = conversion(ton);
c2 = 'FF'
c3 = c1;
}
else {
c1 = conversion(ton);
c2 = c1;
c3 = 'FF'
}
document.write ('<font size=' + koko + ' face=' + tyyppi + ' color="#' + c1 + c2 + c3 + '">' + teksti.substring (i,i+1) + '</font>');
}
}
// -->
</script>
Tämä tulee BODY-osastoon
<!--Seloste:
degrade('Tekstisi tähän',fonttikoon numero [1-7]'fonttinimi',värinumero [0-2])
-->
<div align="left"><script type="text/javascript">
degrade('Tämä on asteittain vaalenevaa tekstiä.',1,'Comic Sans MS',0)
</script></div>
<div align="center"><script type="text/javascript">
degrade('Tämäkin on asteittain vaalenevaa tekstiä.',4,'Arial',1)
</script></div>
<div align="right"><script type="text/javascript">
degrade('Ja tämä on viimeinen värivaihtoehto.',2,'Courier New',2)
</script></div>