bonsoir,
voilà déjà les message d'erreurs avec la console JS de FF :
deprecated arguments usage ligne 12
deprecated arguments usage ligne 14
assignment to undeclared variable roll ligne : 38
reference to undefined property nom[numero] lignes : 40,28,46,35,37
-Visiblement FireFox n'aime pas la fonction objet.
-Il faut écrire :
document.image.src = dossier+nom[numero];
en 2 fois.
voici le code avec quelques modifications :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
<html>
<head>
<script language="JavaScript">
<!--
var roll;
var bauto = 0;
var numero = 1;
//var dossier="C:\Documents and Settings\Mes documents\Mes images\photos_site\PICTURES\";
var dossier="file:/C:/Documents and Settings/Mes documents/Mes images/photos_site/PICTURES/";
/* ou encore avec un chemin relatif :
var dossier="photos_site/PICTURES/";
*/
/*function objet()
{
this.length = objet.arguments.length
for (var i = 0; i < this.length; i++)
this[i+1] = objet.arguments[i]
}
var nom = new objet ("imaga.jpg", "imagb.jpg", "imagc.jpg");
*/
var nom = new Array("imaga.jpg", "imagb.jpg", "imagc.jpg");
function suivante() {
numero += 1;
if (numero == nom.length + 1)
{
numero = 1;
}
//document.image.src = dossier+nom[numero];
var img=nom[numero];
document.image.src = dossier+img;
}
function precedente() {
numero -= 1;
if (numero == 0)
{
numero = nom.length;
}
//document.image.src = dossier+nom[numero];
var img=nom[numero];
document.image.src = dossier+img;
}
function changer() {
numero += 1;
if (numero == nom.length + 1)
{
numero = 1;
}
//document.image.src = dossier+nom[numero];
var img=nom[numero];
document.image.src = dossier+img;
roll=setTimeout("changer()", 1500);
}
function initial() {
window.clearTimeout(roll);
//document.image.src = dossier+nom[numero];
var img=nom[numero];
document.image.src = dossier+img;
}
function auto() {
if (bauto == 0) {
bauto =1;
changer();
document.vision.automat.value=" Lect/Stop ";
}
else {
bauto =0;
initial();
document.vision.automat.value=" Lect/Auto ";
}
}
//-->
</script>
</head>
<body>
<form name="vision">
<div align="center">
<input type="button" name="precedent" value="Précédente" onClick="precedente();">
<input type="button" name="suivant" value=" Suivante " onClick="suivante();">
<input type="button" name="automat" value=" Lect/Auto "onClick="auto();">
</div>
</form>
<div align="center"> <img src="file:/C:/Documents and Settings/Mes documents/Mes images/photos_site/PICTURES/imaga.jpg" width="300" height="200" name="image"></div>
</body>
</html> |
ce code fonctionne avec IE5 et FireFox sans problème.
-J'ai laissé en commentaire le code source original.
-J'ai supprimé la fonction objet que j'ai remplacée par un tableau (array).
-Tu devras modifier les tests des fonctions suivante() , precedente() et changer(). Modifie également l'initialisation de numero.
-Le code
document.image.src = dossier+nom[numero];
devient
1 2
| var img=nom[numero];
document.image.src = dossier+img; |
(affectation en 2 fois)
-J'ai déclaré la variable roll.
-J'ai modifié la syntaxe de src de la balise img.
Partager