Bonjour,
je suis débutant en JavaScript et j'ai récemment réalisé le script suivant. Seulement je constate qu'il ne fonctionne que sous Firefox, d'où la question de savoir comment résoudre ce problème...
Script que l'on retrouve en action à cette adresse: http://www.woo.bplaced.net/box/
Code Javascript :
//Open
function boxopen(){
if(moving){
window.clearInterval(timeval);
}
element.style.background='#0099ff url(right.png) no-repeat';
moving=true;
timeval=window.setInterval('op()',1);
}
function op(){
if(element.clientWidth<boxmax){
width+=5;
width=Math.min(width,boxmax);
element.style.width=width+'px';
}
else{
moving=false;
window.clearInterval(timeval);
}
}
//Close
function boxclose(){
if(moving){
window.clearInterval(timeval);
}
element.style.background='#0099ff url(left.png) no-repeat';
moving=true;
timeval=window.setInterval('cl()',1);
}
function cl(){
if(element.clientWidth>boxmin){
width-=5;
width=Math.max(width,boxmin);
element.style.width=width+'px';
}
else{
moving=false;
window.clearInterval(timeval);
}
}
//Initialiser
function Box(idelement){
element=document.getElementById(idelement);
boxmax=element.clientWidth;
boxmin=0;
element.style.width=boxmin+'px';
element.style.background='#0099ff url(left.png) no-repeat';
width=boxmin;
moving=false;
element.onmouseover = boxopen;
element.onmouseout = boxclose;
}
Merci beaucoup
Jeff