Ciao, sono un principiante. Ho appena incominciato a studiare Javascript e dunque inizio ad avere i primi problemi con gli esercizi.
Quale forum se non questo per chiedere aiuto.![]()
Le due funzioni all'interno dello script di cui sotto dovrebbero ingrandire le dimensioni di un'immagine e diminuire quelle dell'altra, a seconda della scelta.
Tutto questo non accade. La funzione non viene neppure richiamata (ho provato a mettere un alert() come prima istruzione delle funzioni e non appare nulla). Spero non sia un errore di html, non sono molto preparato neanche su quell'argomento. Ecco il codice e spero che qualche anima pia sia disposto a concedermi un po' del suo tempo.
Grazie
codice:<html> <head> <script language="javascript" type="text/javascript"> function img1Win() { var img1 = document.images[0]; var img2 = document.images[1]; var widthDegreeImg1 = img1.width / 100; var widthDegreeImg2 = img2.width / 100; var heightDegreeImg1 = img1.height / 100; var heightDegreeImg2 = img2.height / 100; for(var i = 0; i < 9; i++) { setTimeout( img1.width += widthDegreeImg1; img1.height += heightDegreeImg1; img2.width -= widthDegreeImg2; img2.height -= heightDegreeImg2, 100 ); } } function img2Win() { var img1 = document.getElementById("img1"); var img2 = document.getElementById("img2"); var widthDegreeImg1 = img1.width / 100; var widthDegreeImg2 = img2.width / 100; var heightDegreeImg1 = img1.height / 100; var heightDegreeImg2 = img2.height / 100; for(var i = 0; i < 9; i++) { setTimeout( img2.width += widthDegreeImg2; img2.height += heightDegreeImg2; img1.width -= widthDegreeImg1; img1.height -= heightDegreeImg1, 100 ); } } </script> </head> <body> <div> [img]firefox.jpg[/img][img]chrome.jpg[/img] </div> </body> </html>


Rispondi quotando