Problème javascript?
Résolu
Evanne
-
OlgarK -
OlgarK -
Bonjour,
J'ai copié sur le site le code java un diaporama tout simple, mais il ne marche pas, voici le code:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);
ns3up = (browserName == "Netscape" && browserVer >= 3);
ie4up = (browserName.indexOf("Microsoft") >= 0 && browserVer >= 4);
function doPic(imgName) {
if (ns3up || ie4up) {
imgOn = ("" + imgName);
document.mainpic.src = imgOn;
}
}
// End -->
</script>
<table width=360 border=0 cellspacing=0 cellpadding=0>
<tr>
<td colspan=4 align=center><img name="mainpic"src="P1000735_360.jpg" alt="img" width="365" height="247"></td>
</tr>
<tr>
<td><a href="javascript:doPic('P1000735_360.jpg');"><img src="P1000735_90.jpg" alt="img" width="90" height="62" border=0></a></td>
<td><a href="javascript:doPic('Lifting-2_360.jpg');"><img src="Lifting-2_360.jpg" alt="img" width="90" height="62" border=0></a></td>
<td><a href="javascript:doPic('DSC00987_360.JPG');"><img src="DSC00987_90.JPG" alt="img" width="90" height="62" border=0></a></td>
<td><a href="javascript:doPic('IMG_0372_360.JPG');"><img src="IMG_0372_90.JPG" alt="img" width="90" height="62" border=0></a></td>
<td> </td>
</tr>
</table>
je tourne en rond, si quelqu'un a la gentillesse de me dépanner merci:))
J'ai copié sur le site le code java un diaporama tout simple, mais il ne marche pas, voici le code:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);
ns3up = (browserName == "Netscape" && browserVer >= 3);
ie4up = (browserName.indexOf("Microsoft") >= 0 && browserVer >= 4);
function doPic(imgName) {
if (ns3up || ie4up) {
imgOn = ("" + imgName);
document.mainpic.src = imgOn;
}
}
// End -->
</script>
<table width=360 border=0 cellspacing=0 cellpadding=0>
<tr>
<td colspan=4 align=center><img name="mainpic"src="P1000735_360.jpg" alt="img" width="365" height="247"></td>
</tr>
<tr>
<td><a href="javascript:doPic('P1000735_360.jpg');"><img src="P1000735_90.jpg" alt="img" width="90" height="62" border=0></a></td>
<td><a href="javascript:doPic('Lifting-2_360.jpg');"><img src="Lifting-2_360.jpg" alt="img" width="90" height="62" border=0></a></td>
<td><a href="javascript:doPic('DSC00987_360.JPG');"><img src="DSC00987_90.JPG" alt="img" width="90" height="62" border=0></a></td>
<td><a href="javascript:doPic('IMG_0372_360.JPG');"><img src="IMG_0372_90.JPG" alt="img" width="90" height="62" border=0></a></td>
<td> </td>
</tr>
</table>
je tourne en rond, si quelqu'un a la gentillesse de me dépanner merci:))
Configuration: Windows XP Firefox 3.0.4
6 réponses
-
Je suppose que tu as fait un copier/coller.
Je vois dans l'immédiat ça :
<td colspan=4 align=center><img name="mainpic"src="P1000735_360.jpg" alt="img" width="365" height="247"></td>
Mets un espace avant 'src'. -
Peux-tu essayer d'ajouter l'id mainpic comme ceci dans ta première balise img :
name="mainpic" id="mainpic" -
Tu ajoutes la modif suivante aux modifs déjà mentionnées plus haut.
Tu remplaces la ligne : document.mainpic.src = imgOn;
par : document.getElementById('mainpic').src = imgOn; -
-
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question -
-
Voici des pistes simples, mais je ne développe pas.
La première "grande" image tu lui donnes par exemple l'id "gdeimage1".
La seconde "gdeimage2", etc...
Dans le premier groupe d'images, quand on clickes sur une miniature, il faut qu'on appelles une fonction javascript avec 2 paramètres : nomImage et numeroCible.
La fonction en question pourrait être :
function doPic(imgName, numeroCible) {
document.getElementById('gdeimage'+numeroCible).src = imgName;
}
}