Variable undefined alors qu'elle existe.
Salut,
Je ne comprends pas, j'ai une erreur javascript au niveau de la ligne:
photos[num_chapter].src = photos_url[num_chapter] ;
Et cela me dit:
photos[num_chapter] is undefined.
Pourtant la variable photos existe bien, regardez le code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
<script language="JavaScript">
var photos_url = new Array() ;
var photos = new Array();
photos_url[0] = "http://localhost:8888/Works/ElizaNet/0.jpg" ;
photos[0] = new Image();
photos_url[1] = "http://localhost:8888/Works/ElizaNet/1.jpg" ;
photos[1] = new Image();
photos_url[2] = "http://localhost:8888/Works/ElizaNet/2.jpg" ;
photos[2] = new Image();
photos_url[3] = "http://localhost:8888/Works/ElizaNet/3.jpg" ;
photos[3] = new Image();
photos_url[4] = "http://localhost:8888/Works/ElizaNet/4.jpg" ;
photos[4] = new Image();
photos_url[5] = "http://localhost:8888/Works/ElizaNet/5.jpg" ;
photos[5] = new Image();
function JS_change_chapter(num_chapter) {
photos[num_chapter].src = photos_url[num_chapter] ;
//document.getElementById('img_chapter').src = 'http://localhost:8888/Works/ElizaNet/imgs/picbooks/1/1.jpg' ;
document.getElementById('img_chapter').src = photos[num_chapter] ;
} |
Vous auriez une idée ? La je bloque depuis longtemps sur cette erreur...
Merci,
Vincent.