Accueil > > > BOUTON STYLE FLASH
BOUTON STYLE FLASH
Information sur la source
Description
Hello! Ne soyez pas trop severe, je debute en javascript et c'est ma premiere source... Je l'ai un peu commentee mais c'est assez simple a comprendre =) Le principe est simple, des qu'on passe sur une cellule, la fonction change peu a peu le background et le texte de la cellule en donnant un effet comme en flash ^^ Je ne sais pas que dire d'autre... Ce n'est pas tres optimise mais comme je l ai dit je debute ^^ je serai ravi d'ameliorer mon code grace a vos critiques... Pour un exemple live, mon site : http://www.kezako.fr.fm
Source
- <HTML><HEAD>
- <META http-equiv=Content-Type content="text/html; charset=windows-1252">
-
- <SCRIPT language=javascript type=text/javascript>
-
- //Flash button by Goulagman <goulagman@wanadoo.fr>
- //definition des vars
- cod = '#E9EBFF' //couleur de depart du fond
- cof = '#8A96FF' //couleur finale du fond
- tod = '#0000ff' //couleur de depart du texte
- tof = '#F2F3FF' //couleur finale du texte
- step1 = '23' //pas pendant que le bouton fonce
- step2 = '40' //pas pendant que le bouton s'eclaircit ( il s eclaircit plus lentement qu'il ne fonce )
-
-
-
-
- function Hexa(Dec) { //Conversion Hexadecimal > decimal
- var n = Dec.toString(16)
- if (n.length < 2) {n = "0" + n}
- return(n)
- }
-
- function Dec(Hexa) { //Conversion decimal > Hexadecimal
- var n = parseInt(Hexa, 16)
- return(n)
- }
-
- function ToHex(n) { //Conversion couleur RGB > Hexa
- str=n
- var reg = new RegExp("[rgb\\(',\\)]", "i");
- res = str.split(reg);
- m='#'
- for (var i=0;i<str.length;i++) {
- var reg = new RegExp("[0-9]+", "i");
- if (reg.test(res[i])) {
- m=m + Hexa(parseInt(res[i]));
- }
- }
- return(m)
- }
-
- function couleur(id, cd, cf, td, tf, step) {
- if (navigator.appVersion.indexOf("MSIE") == -1){
- if (cd) { cd=ToHex(cd) }
- if (td) { td=ToHex(td) }
- }
- if (!cd ) { cd = cod }
- if (!td ) { td = tod }
-
- //On arrete le timer si le bouton est deja en trian de changer de couleur
- clearTimeout(col[id])
-
- //calcul des RGB de debut et de fin du texte et du fond
- rd=Dec(cd.substring(1,3))
- vd=Dec(cd.substring(3,5))
- bd=Dec(cd.substring(5,7))
- rf=Dec(cf.substring(1,3))
- vf=Dec(cf.substring(3,5))
- bf=Dec(cf.substring(5,7))
- rtd=Dec(td.substring(1,3))
- vtd=Dec(td.substring(3,5))
- btd=Dec(td.substring(5,7))
- rtf=Dec(tf.substring(1,3))
- vtf=Dec(tf.substring(3,5))
- btf=Dec(tf.substring(5,7))
-
- //calcul du step par couleur
- sr=((rf-rd)/step)
- sv=((vf-vd)/step)
- sb=((bf-bd)/step)
- str=((rtf-rtd)/step)
- stv=((vtf-vtd)/step)
- stb=((btf-btd)/step)
-
- //changement de la couleur
- rt = rd;vt = vd;bt = bd
- rtt = rtd;vtt = vtd;btt = btd
- adv = 0
- changecolor(id, rt, vt, bt, sr, sv, sb, rtt, vtt, btt, str, stv, stb, adv, step)
- }
-
- function changecolor(id, rt, vt, bt, sr, sv, sb, rtt, vtt, btt, str, stv, stb, adv, step) {
- document.getElementById(id).style.backgroundColor='#' + Hexa(Math.floor(rt)) + Hexa(Math.floor(vt)) + Hexa(Math.floor(bt))
- document.getElementById(id).style.color='#' + Hexa(Math.floor(rtt)) + Hexa(Math.floor(vtt)) + Hexa(Math.floor(btt))
-
- //on ajoute le pas de chaque couleur
- rt += sr;vt += sv;bt += sb
- rtt += str;vtt += stv;btt += stb
-
- adv++
- if ( adv != step+1 ) { col[id] = setTimeout('changecolor('+id+', '+rt+', '+vt+', '+bt+', '+sr+', '+sv+', '+sb+', '+rtt+', '+vtt+', '+btt+', '+str+', '+stv+', '+stb+', '+adv+', '+step+')',15) }
- else { col[id] = 1 }
- }
- </SCRIPT>
- <STYLE type=text/css>
- .titre {
- FONT-SIZE: 10px; COLOR: #ffffff; FONT-FAMILY: arial; BACKGROUND-COLOR: #7c88ff
- }
- .cell {
- FONT-SIZE: 10px; COLOR: #0000ff; FONT-FAMILY: arial
- }
-
- </STYLE>
-
-
-
- </HEAD>
- <BODY
- onload="col = new Object()">
- <CENTER>
- <TABLE style="BORDER-TOP-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-LEFT-STYLE: solid; BORDER-BOTTOM-STYLE: solid" borderColor=blue cellSpacing=2 cellPadding=3 bgColor=#b2b9ff border=1>
- <TR>
- <TD vAlign=top width=100 bgColor=white>
- <TABLE borderColor=blue cellSpacing=0 cellPadding=1 bgColor=#e9ebff
- border=0>
- <TR>
- <TD class=titre width=100 height=14>
- <CENTER>Site</CENTER></TD></TR>
- <TR>
- <TD class=cell id=1
- style="CURSOR: hand"
- onclick="alert('Bouton Acceuil clické')"
- onmouseover="couleur(1, this.style.backgroundColor, cof, this.style.color, tof, step1)"
- onmouseout="couleur(1, this.style.backgroundColor, cod, this.style.color, tod, step2)">-
- Accueil</TD></TR>
- <TR>
- <TD class=cell id=2
- style="CURSOR: hand"
- onclick="alert('Bouton Liens clické')"
- onmouseover="couleur(2, this.style.backgroundColor, cof, this.style.color, tof, step1)"
- onmouseout="couleur(2, this.style.backgroundColor, cod, this.style.color, tod, step2)">-
- Liens</TD></TR>
- <TR>
- <TD class=cell id=3
- style="CURSOR: hand"
- onclick="alert('Bouton Contact clické')"
- onmouseover="couleur(3, this.style.backgroundColor,cof, this.style.color, tof, step1)"
- onmouseout="couleur(3, this.style.backgroundColor, cod, this.style.color, tod, step2)">-
- Contact
- </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
-
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<SCRIPT language=javascript type=text/javascript>
//Flash button by Goulagman <goulagman@wanadoo.fr>
//definition des vars
cod = '#E9EBFF' //couleur de depart du fond
cof = '#8A96FF' //couleur finale du fond
tod = '#0000ff' //couleur de depart du texte
tof = '#F2F3FF' //couleur finale du texte
step1 = '23' //pas pendant que le bouton fonce
step2 = '40' //pas pendant que le bouton s'eclaircit ( il s eclaircit plus lentement qu'il ne fonce )
function Hexa(Dec) { //Conversion Hexadecimal > decimal
var n = Dec.toString(16)
if (n.length < 2) {n = "0" + n}
return(n)
}
function Dec(Hexa) { //Conversion decimal > Hexadecimal
var n = parseInt(Hexa, 16)
return(n)
}
function ToHex(n) { //Conversion couleur RGB > Hexa
str=n
var reg = new RegExp("[rgb\\(',\\)]", "i");
res = str.split(reg);
m='#'
for (var i=0;i<str.length;i++) {
var reg = new RegExp("[0-9]+", "i");
if (reg.test(res[i])) {
m=m + Hexa(parseInt(res[i]));
}
}
return(m)
}
function couleur(id, cd, cf, td, tf, step) {
if (navigator.appVersion.indexOf("MSIE") == -1){
if (cd) { cd=ToHex(cd) }
if (td) { td=ToHex(td) }
}
if (!cd ) { cd = cod }
if (!td ) { td = tod }
//On arrete le timer si le bouton est deja en trian de changer de couleur
clearTimeout(col[id])
//calcul des RGB de debut et de fin du texte et du fond
rd=Dec(cd.substring(1,3))
vd=Dec(cd.substring(3,5))
bd=Dec(cd.substring(5,7))
rf=Dec(cf.substring(1,3))
vf=Dec(cf.substring(3,5))
bf=Dec(cf.substring(5,7))
rtd=Dec(td.substring(1,3))
vtd=Dec(td.substring(3,5))
btd=Dec(td.substring(5,7))
rtf=Dec(tf.substring(1,3))
vtf=Dec(tf.substring(3,5))
btf=Dec(tf.substring(5,7))
//calcul du step par couleur
sr=((rf-rd)/step)
sv=((vf-vd)/step)
sb=((bf-bd)/step)
str=((rtf-rtd)/step)
stv=((vtf-vtd)/step)
stb=((btf-btd)/step)
//changement de la couleur
rt = rd;vt = vd;bt = bd
rtt = rtd;vtt = vtd;btt = btd
adv = 0
changecolor(id, rt, vt, bt, sr, sv, sb, rtt, vtt, btt, str, stv, stb, adv, step)
}
function changecolor(id, rt, vt, bt, sr, sv, sb, rtt, vtt, btt, str, stv, stb, adv, step) {
document.getElementById(id).style.backgroundColor='#' + Hexa(Math.floor(rt)) + Hexa(Math.floor(vt)) + Hexa(Math.floor(bt))
document.getElementById(id).style.color='#' + Hexa(Math.floor(rtt)) + Hexa(Math.floor(vtt)) + Hexa(Math.floor(btt))
//on ajoute le pas de chaque couleur
rt += sr;vt += sv;bt += sb
rtt += str;vtt += stv;btt += stb
adv++
if ( adv != step+1 ) { col[id] = setTimeout('changecolor('+id+', '+rt+', '+vt+', '+bt+', '+sr+', '+sv+', '+sb+', '+rtt+', '+vtt+', '+btt+', '+str+', '+stv+', '+stb+', '+adv+', '+step+')',15) }
else { col[id] = 1 }
}
</SCRIPT>
<STYLE type=text/css>
.titre {
FONT-SIZE: 10px; COLOR: #ffffff; FONT-FAMILY: arial; BACKGROUND-COLOR: #7c88ff
}
.cell {
FONT-SIZE: 10px; COLOR: #0000ff; FONT-FAMILY: arial
}
</STYLE>
</HEAD>
<BODY
onload="col = new Object()">
<CENTER>
<TABLE style="BORDER-TOP-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-LEFT-STYLE: solid; BORDER-BOTTOM-STYLE: solid" borderColor=blue cellSpacing=2 cellPadding=3 bgColor=#b2b9ff border=1>
<TR>
<TD vAlign=top width=100 bgColor=white>
<TABLE borderColor=blue cellSpacing=0 cellPadding=1 bgColor=#e9ebff
border=0>
<TR>
<TD class=titre width=100 height=14>
<CENTER>Site</CENTER></TD></TR>
<TR>
<TD class=cell id=1
style="CURSOR: hand"
onclick="alert('Bouton Acceuil clické')"
onmouseover="couleur(1, this.style.backgroundColor, cof, this.style.color, tof, step1)"
onmouseout="couleur(1, this.style.backgroundColor, cod, this.style.color, tod, step2)">-
Accueil</TD></TR>
<TR>
<TD class=cell id=2
style="CURSOR: hand"
onclick="alert('Bouton Liens clické')"
onmouseover="couleur(2, this.style.backgroundColor, cof, this.style.color, tof, step1)"
onmouseout="couleur(2, this.style.backgroundColor, cod, this.style.color, tod, step2)">-
Liens</TD></TR>
<TR>
<TD class=cell id=3
style="CURSOR: hand"
onclick="alert('Bouton Contact clické')"
onmouseover="couleur(3, this.style.backgroundColor,cof, this.style.color, tof, step1)"
onmouseout="couleur(3, this.style.backgroundColor, cod, this.style.color, tod, step2)">-
Contact
</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
Conclusion
Pas de bugs connus ^^
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
MYTIC - SHAREPOINT 2010 : DéJà UN MYTHE MICROSOFT ?MYTIC - SHAREPOINT 2010 : DéJà UN MYTHE MICROSOFT ? par junarnoalg
La prochaine session de MyTIC aura lieu à Namur, le 23 mars prochain. Pendant presque une heure, nous parlerons de SharePoint 2010. Voici un aperçu du programme.
Accueil : 17h30 Début de la session : 18h00 - Les nouvelles int...
Cliquez pour lire la suite de l'article par junarnoalg [MIX10] KEYNOTE DEUXIèME JOURNéE - INTERNET EXPLORER 9, HTML5, VISUAL STUDIO 2010, ODATA[MIX10] KEYNOTE DEUXIèME JOURNéE - INTERNET EXPLORER 9, HTML5, VISUAL STUDIO 2010, ODATA par cyril
Le deuxième keynote du mix fut très riche en contenu. Internet Explorer 9 Juste un après le lancement de Internet Explorer 8, Microsoft a dévoilé les nouveautés de Internet Explorer 9. Désormais, IE supportera HTML5, SVG et CSS3. L'élément ...
Cliquez pour lire la suite de l'article par cyril CERTIFICATIONS BETA .NET 4CERTIFICATIONS BETA .NET 4 par KooKiz
Les inscriptions pour les certifications beta .NET 4 ont commencé. L'inscription est offerte pour les examens suivants : - 71-511, TS: Windows Applications Development with Microsoft .NET Framework 4 - 71-515, TS: Web Applications Development with...
Cliquez pour lire la suite de l'article par KooKiz [MIX 2010] - MICROSOFT TRANSLATOR TECHNOLOGY PREVIEW V2[MIX 2010] - MICROSOFT TRANSLATOR TECHNOLOGY PREVIEW V2 par redo
J'imagine que la plupart d'entre vous connaissent bien et utilisent le service de traduction de Google, mais connaissez-vous celui de Microsoft . Microsoft Translator ? Effectivement, Microsoft nous annoncé le lancement version 2 de la Technologie Preview...
Cliquez pour lire la suite de l'article par redo
Logiciels
Academy System (10.9.4.0)ACADEMY SYSTEM (10.9.4.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Xilisoft Convertisseur Vidéo Ultimate (5.1.39.0305)XILISOFT CONVERTISSEUR VIDéO ULTIMATE (5.1.39.0305)Xilisoft Convertisseur Vidéo Ultimate est un outil puissant de conversion vidéo, facile à utilise... Cliquez pour télécharger Xilisoft Convertisseur Vidéo Ultimate Xilisoft DVD Ripper Ultimate (5.0.64.0304)XILISOFT DVD RIPPER ULTIMATE (5.0.64.0304)Xilisoft DVD Ripper Ultimate est un logiciel excellent pour copier et convertir DVD vers presque ... Cliquez pour télécharger Xilisoft DVD Ripper Ultimate Rigs of Rods (63.3)RIGS OF RODS (63.3)c'est un jeu de multi-simulation camions,autobus voitures, avions, bateaux, hélicoptère avec défo... Cliquez pour télécharger Rigs of Rods
Comparez les prix

HTC Magic
Entre 429€ et 429€
|