Forum-webmaster
Technique - programmation => Javascript / DOM / Ajax => Message commencé par: cdv le le 13-12-2006 a 15:40:25

Titre: problème script zoom image
Posté par: cdv le le 13-12-2006 a 15:40:25

Bonjour, l'exécution du script zoom image ne fonctionne pas avec mes 6 images alors qu'il fonctionnait bien avec une seule.
Des idées ?
Merci !
<html>

<head>
<meta http-equiv="Content-Language" content="fr">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<style type="text/css">
texte
{
   font-family: "Comic Sans MS";
   color:#8C3C29;
}
titre
{
   font-weight: bold;
   color:red;
}
</style>

<title>Agenda</title>
<script language="JavaScript">
<!--
function FP_preloadImgs() {//v1.0
var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
for(var i=0; i<a.length; i++) { d.FP_imgs=new Image; d.FP_imgs.src=a; }
}
// -->
</script>

<script language="JavaScript">
<!--
//PLF-http://www.jejavascript.net/
var coeff=5;//Coefficient de reduction
var larg=500;//largeur maxi de l'image
var haut=500;//hauteur maxi de l'image
function changer(sel) {
switch(sel){
case 1 : //image 1
if (document.image1.width < larg) {
coeff = coeff-0.2;
document.image1.width = Math.round(larg/coeff);
document.image1.height = Math.round(haut/coeff);
chang=window.setTimeout('changer(1);',60);//vitesse de l'effet
}
break;
case 2 : //image 2
if (document.image2.width < larg) {
coeff = coeff-0.2;
document.image2.width = Math.round(larg/coeff);
document.image2.height = Math.round(haut/coeff);
chang=window.setTimeout('changer(2);',60);//vitesse de l'effet
}
break;
case 3 : //image 3
if (document.image3.width < larg) {
coeff = coeff-0.2;
document.image3.width = Math.round(larg/coeff);
document.image3.height = Math.round(haut/coeff);
chang=window.setTimeout('changer(3);',60);//vitesse de l'effet
}
break;
case 4 : //image 4
if (document.image3.width < larg) {
coeff = coeff-0.2;
document.image4.width = Math.round(larg/coeff);
document.image4.height = Math.round(haut/coeff);
chang=window.setTimeout('changer(3);',60);//vitesse de l'effet
}
break;
case 5 : //image 5
if (document.image3.width < larg) {
coeff = coeff-0.2;
document.image5.width = Math.round(larg/coeff);
document.image5.height = Math.round(haut/coeff);
chang=window.setTimeout('changer(3);',60);//vitesse de l'effet
}
break;
case 6 : //image 6
if (document.image3.width < larg) {
coeff = coeff-0.2;
document.image6.width = Math.round(larg/coeff);
document.image6.height = Math.round(haut/coeff);
chang=window.setTimeout('changer(3);',60);//vitesse de l'effet
}

if (document.image2.width >= larg) window.clearTimeout(chang);
}
function initial(sel) {
switch(sel){
case 1 : //image 1
if (document.image1.width > larg/4) {
window.clearTimeout(chang);
coeff = coeff+0.2;
document.image1.width = Math.round(larg/coeff);
document.image1.height = Math.round(haut/coeff);
initi=window.setTimeout('initial(1);',60);//vitesse de l'effet
}
break;
case 2 : //image 2
if (document.image2.width > larg/4) {
window.clearTimeout(chang);
coeff = coeff+0.2;
document.image2.width = Math.round(larg/coeff);
document.image2.height = Math.round(haut/coeff);
initi=window.setTimeout('initial(2);',60);//vitesse de l'effet
}
break;
case 3 : //image 3
if (document.image3.width > larg/4) {
window.clearTimeout(chang);
coeff = coeff+0.2;
document.image3.width = Math.round(larg/coeff);
document.image3.height = Math.round(haut/coeff);
initi=window.setTimeout('initial(3);',60);//vitesse de l'effet
}
break;
case 4 : //image 4
if (document.image4.width > larg/4) {
window.clearTimeout(chang);
coeff = coeff+0.2;
document.image4.width = Math.round(larg/coeff);
document.image4.height = Math.round(haut/coeff);
initi=window.setTimeout('initial(4);',60);//vitesse de l'effet
}
break;
case 5 : //image 5
if (document.image5.width > larg/4) {
window.clearTimeout(chang);
coeff = coeff+0.2;
document.image5.width = Math.round(larg/coeff);
document.image5.height = Math.round(haut/coeff);
initi=window.setTimeout('initial(5);',60);//vitesse de l'effet
}
break;
case 6 : //image 6
if (document.image6.width > larg/4) {
window.clearTimeout(chang);
coeff = coeff+0.2;
document.image6.width = Math.round(larg/coeff);
document.image6.height = Math.round(haut/coeff);
initi=window.setTimeout('initial(6);',60);//vitesse de l'effet
}
if (document.image1.width < larg/4) window.clearTimeout(initi);
}
//-->
</script>

</head>

<body background="fond%20clair.jpg" onload="FP_preloadImgs(/*url*/'button45.jpg')">

      <p class="MsoNormal" style="text-align:justify">
      <font color="#FFFFFF">
      <span style="font-family: Comic Sans MS; background-color: #8C3C29" lang="FR-BE">
      <font size="4">&nbsp; <b>Agenda&nbsp;</b></font></span></font></p>
      <p class="MsoNormal" style="text-align:justify">
      &nbsp;</p>
      <p class="MsoNormal" style="text-align:center">
      <img border="0" src="invit%201er%20page.jpg" width="440" height="446"><img border="0" src="fichiers/courte%20echelle/invit%20derniere%20page.jpg" width="448" height="447"></p>
      <p align="center">
      &nbsp;

      <font color="#8C3C29" size="2">
            <span style="font-family: Comic Sans MS; font-style: italic">
            (découvrez le programme en survolant les images ci-dessous)<br>
      <br>
&nbsp;
<a href="#" onMouseOut="initial(1)" onMouseOver="changer(1)" >
      <img src="fichiers/courte%20echelle/janvier.jpg" name="image1" border="0" width="230" height="239"></a>
<script language="JavaScript">
<!--
//PLF-http://www.jejavascript.net/
document.image1.width = Math.round(larg/coeff);
document.image1.height = Math.round(haut/coeff);
//-->
</script>

&nbsp; &nbsp;

<a href="#" onMouseOut="initial(2)" onMouseOver="changer(2)" >
      <img src="fichiers/courte%20echelle/fevrier.jpg" name="image2" border="0" width="233" height="239"></a>
<script language="JavaScript">
<!--
//PLF-http://www.jejavascript.net/
document.image2.width = Math.round(larg/coeff);
document.image2.height = Math.round(haut/coeff);
//-->
</script>

</span></font>
<p align="center">
      &nbsp;
      <a href="#" onMouseOut="initial(3)" onMouseOver="changer(3)" >
      <img src="fichiers/courte%20echelle/mars.jpg" name="image1" border="0" width="235" height="239"></a>
<script language="JavaScript">
<!--
//PLF-http://www.jejavascript.net/
document.image3.width = Math.round(larg/coeff);
document.image3.height = Math.round(haut/coeff);
//-->
</script>

&nbsp;&nbsp;

<a href="#" onMouseOut="initial(4)" onMouseOver="changer(4)" >
      <img src="fichiers/courte%20echelle/avril.jpg" name="image4" border="0" width="240" height="239"></a>
<script language="JavaScript">
<!--
//PLF-http://www.jejavascript.net/
document.image4.width = Math.round(larg/coeff);
document.image4.height = Math.round(haut/coeff);
//-->
</script>




      &nbsp;


      <p align="center">
      &nbsp;
      
      <a href="#" onMouseOut="initial(5)" onMouseOver="changer(5)" >
      <img src="fichiers/courte%20echelle/mai.jpg" name="image5" border="0" width="236" height="235"></a>
<script language="JavaScript">
<!--
//PLF-http://www.jejavascript.net/
document.image5.width = Math.round(larg/coeff);
document.image5.height = Math.round(haut/coeff);
//-->
</script>
&nbsp;&nbsp;
<a href="#" onMouseOut="initial(6)" onMouseOver="changer(6)" >
      <img src="fichiers/courte%20echelle/juin.jpg" name="image6" border="0" width="240" height="239"></a>
<script language="JavaScript">
<!--
//PLF-http://www.jejavascript.net/
document.image6.width = Math.round(larg/coeff);
document.image6.height = Math.round(haut/coeff);
//-->
</script>

Titre: Re:problème script zoom image
Posté par: apache le le 13-02-2007 a 01:25:37

Bonjour,
je pense qu'il y a quelques éléments à modifier dans ton script :
1- dans la partie où il y a "coeff=coeff-0.2" il faut que le numéro de "image" dans "if (document.image3.width < larg) {" corresponde au numéro de "case 6 : //image 6" (tu ne peux pas écrire "document.image3" alors qu'il y a au dessus "case 6 : //image 6")
2- dans la partie où il y a "coeff=coeff+0.2" tu ne peux pas écrire "larg/4" alors que tout en haut tu écris "var coeff=5"

J'espère avoir été clair
Bon courage

Apache ;)


Forum-webmaster | Actionné par YaBB SE
© 2001-2003, YaBB SE Dev Team. Tous droits réservés.