image_list.php
Codice PHP:
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src"image_browser.js"></script>
</head>

<body onload="javascript:init()">
<h1>Album fotografico </h1>
[img]ajax-loader.gif[/img]


<?
echo '[';

$v scandir('images/*');
for(
$i =0$i count($v);$i++){
echo 
'"' $v$i ] . '"';
if(
$i != count($v) -1){
echo 
',';
}
    echo 
"\n";
}
echo 
']';
?>
[url="javascript:avanti()"]Avanti[/url]
[url="javascript:indietro()"]Indietro[/url]
</body>
</html>


image_browser.js

codice:
// JavaScript Document
var count = 0;
var name_list;
function init(){
list();
setTimeout("load(0)",0);	
}

function load(i){
var img = new Image();
img.src="images/*" + name_list[i];
if (i ==0){
setImage();	
}
i++;
if(i != name_list.length - 1){
	
setTimeout("load(" + i + ")",250);	
}
	
}

function setImage(){
document.getElementById("photo").src = "images/*" + name_list[count];	
}

function list(){
var oXHR = new XMLHttpRequest();
oXHR.open("get","image_list.php",false);
oXHR.send(null);
var json = oXHR.responseText;
name_list = eval(json);	
	
}

function avanti(){
	count++;
	if(count == name_list.length){
		count=0;
	}
	setImage();
}

function indietro(){
	count--;
	if(count == -1){
		count=name_list.length-1;
	}
	setImage();
}
dovrebbe sfogliarmi una cartella e precaricare la foto successiva in modo da non far attendere gli utenti, ma non riesco a farla funzionare
qualcuno ci puo' dare un occhio?

grazie