hey, ik heb nu een preloader script voor mijn website, hij blijft alleen telkens hangen, hier een link naar de pagina hopelijk kan iemand mij helpen http://lecowow.selfip.net/index2.php.
Bron
index2.php
Loader.js
Bedankt voor je tijd, Xeross
Bron
index2.php
Code:
<?php
function rscandir($base='', &$data=array()) {
$array = array_diff(scandir($base), array('.', '..')); # remove ' and .. from the array */
foreach($array as $value) : /* loop through the array at the level of the supplied $base */
if (is_dir($base.$value)) : /* if this is a directory */
$data[] = $base.$value.'/'; /* add it to the $data array */
$data = rscandir($base.$value.'/', $data); /* then make a recursive call with the
current $value as the $base supplying the $data array to carry into the recursion */
elseif (is_file($base.$value)) : /* else if the current $value is a file */
$data[] = $base.$value; /* just add the current $value to the $data array */
endif;
endforeach;
return $data; // return the $data array
}
$Files = rscandir("Site/Images/");
foreach ($Files as &$File) {
if(!strstr($File, "favicon.ico")) {
$String .= "['" . $File . "', " . round(filesize($File) / 1000, 2) . "],";
}
}
?>
<html>
<head>
<title>Preload Image Page</title>
<!-- START LOADER -->
<style type="text/css">
#bt_container {font-family:courier, serif; font-size:9px;}
</style>
<script type="text/javascript">
// Time in seconds to wait before giving up on preload (broken
// images can cause the load to never get to 100%).
var bt_timeout = 100;
// Array of images to load; feel free to make this as long or
// as short as you want. First element is filename (include path
// to file), second is size of images in kB.
var bt_preimages = [
<?php echo substr($String, 0, -1); ?>
];
// Text to use for when loading has finished
var bt_text_finished = 'Done';
// Text to prefix the percentage
var bt_text_prefix = 'Loaded: ';
function bt_done() {
// stub function called when script is finished, put your JS here.
// (you could use a javascript to redirect the user)
}
</script>
<script type="text/javascript" src="Loader.js"></script>
<!-- END LOADER -->
</head>
<body bgcolor="#FFFFFF">
</body>
</html>
Loader.js
Code:
// Simple DHTML Image Loader
// by Glen Murphy. Script located at http://bodytag.org/
function bt_forcedone() {
document.getElementById('bt_container').innerHTML = bt_text_finished;
bt_done();
}
function bt_arrived(o) {
bt_loaded += bt_preimages[o][1];
var bt_percentage = Math.round((bt_loaded/bt_total)*100);
document.getElementById('bt_container').innerHTML = bt_text_prefix+bt_percentage+'% ' + bt_preimages[o][0] + ' Size ' + bt_preimages[o][1];
if(bt_percentage == 100) {
bt_forcedone();
}
}
if(bt_timeout > 0) {
setTimeout('bt_forcedone()',bt_timeout*1000);
}
var bt_total = 0;
var bt_loaded = 0;
var bt_out = '';
bt_out += '<div id="bt_container">Preloading..</div>';
for(i = 0; i < bt_preimages.length; i++) {
bt_total += bt_preimages[i][1];
bt_out += '<img src="'+bt_preimages[i][0]+'" width="1" height="1" onload="bt_arrived('+i+');" style="position:absolute; top:-1000px;" />';
}
document.write(bt_out);
Bedankt voor je tijd, Xeross