Codice PHP:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="it">
<head>
<title>Immagini in sequenza</title>
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Language" content="it" />
<script type="text/javascript" language="JavaScript">
<!--
n = (document.layers) ? 1:0
ie = (document.all) ? 1:0
function init() {
numImgAnim = new GifAnim('numDiv','numImg','num',5,200)
}
function preload() {
for (var i=0; i<arguments.length; i++) {
eval(arguments[i]+' = new Image()')
eval(arguments[i]+'.src = "'+arguments[i]+'.gif"')
}
}
for (var i=0;i<=5;i++) preload('num'+i)
function changeImage(layer,imgName,imgObj) {
if (n && layer!=null) eval('document.'+layer+'.document.images["'+imgName+'"].src = '+imgObj+'.src');
else document.images[imgName].src = eval(imgObj+".src");
}
function GifAnim(layer,imgName,imgSeries,end,speed,startFrame) {
this.layer = layer
this.imgName = imgName
this.frame = new Array()
for (var i=0; i<=end; i++) this.frame[i] = imgSeries+i
this.end = end
this.speed = speed
this.active = false
this.count = (startFrame)? startFrame : 0
this.obj = imgName + "Object"
eval(this.obj + "=this")
this.play = GifAnimPlay
this.run = GifAnimRun
this.stop = GifAnimStop
this.goToFrame = GifAnimGoToFrame
}
function GifAnimPlay(loop,reset,fn) {
if (!this.active) {
this.active = true
if (!loop) loop = false
if (!reset) reset = false
if (!fn) fn = null
this.run(loop,reset,fn)
}
}
function GifAnimRun(loop,reset,fn) {
if (this.active && this.count <= this.end) {
changeImage(this.layer,this.imgName,this.frame[this.count])
this.count += 1
setTimeout(this.obj+".run("+loop+","+reset+",\""+fn+"\")",this.speed)
}
else {
if (loop && this.active) {
this.count = 0
this.run(loop,reset,fn)
}
else {
this.active = false
if (reset) this.goToFrame(0)
eval(fn)
}
}
}
function GifAnimStop() {
this.active = false
}
function GifAnimGoToFrame(index) {
this.count = index
changeImage(this.layer,this.imgName,this.frame[this.count])
}
//-->
</script>
<style type="text/css">
<!--
#numDiv {position:absolute; left:250; top:75; width:50;}
//-->
</head>
<body >
<div align="center">
<style type="text/css">
<!--
#numDiv {position:absolute; left:250; top:75; width:50;}
-->
</style></head><body onload="init()" bgcolor="white">
[url="javascript:numImgAnim.play()"]Play[/url]
[url="javascript:numImgAnim.play(true)"]Play (infinito)[/url]
[url="javascript:numImgAnim.stop()"]Stop[/url]
Immagini:
[url="javascript:numImgAnim.goToFrame(0)"]0[/url]
[url="javascript:numImgAnim.goToFrame(1)"]1[/url]
[url="javascript:numImgAnim.goToFrame(2)"]2[/url]
[url="javascript:numImgAnim.goToFrame(3)"]3[/url]
[url="javascript:numImgAnim.goToFrame(4)"]4[/url]
[url="javascript:numImgAnim.goToFrame(5)"]5[/url]
<div id="numDiv">
[img]http://www.html.it/dynamic/grafica/num5.gif[/img]
</div>
</div>
</body>
</html>
Ciao a tutti ho scaricato l'esempio per far scorrere le immagini ai miei utenti!
Io ho 5 immagini!
L'utente all'inizio visualizza "1.jpg"
Ci sono affianco i pulsanti "<<" ">>"
Che spostano l'immagine alla "2.jpg" o alla "5.jpg" e così via!
Come posso modificarlo??