Alain: meine version und lösung ...

Beitrag lesen

Hallo twb!
falls es Dich interessiert,das script unterstützt alle browser die ich kenne bzw. habe im gegensatz zu deiner version.
Ich poste mal das komplette script hier:
var image=new Array ('bild1.jpg','bild2.jpg','bild3.jpg'...ect.);

var ypos=180; //POSITION OF LOAD BAR FROM TOP OF WINDOW, IN PIXELS
var loadcol='aqua' ;    // PROGRESS BAR COLOR
var unloadcol='blue';  // BGCOLOR OF UNLOADED AREA
var barheight=20;     // HEIGHT OF PROGRESS BAR IN PIXELS (MIN 20)
var barwidth=400;    // WIDTH OF THE BAR IN PIXELS
var bordcol='black';// COLOR OF THE BORDER

var DOM=false, IE=false, NS4=false, OP=false;
if (window.opera)
{
OP=true;
}
else if (document.getElementById&&!document.all) {
DOM=true;
}
else if (document.all) {
IE=true;
}
else if (document.layers) {
NS4=true;
}

var size=barwidth/(image.length);
barheight=Math.max(barheight,20);
var imgdone=false;
var count=0, outer, done, img=new Array();
if(NS4||IE){
var txt=(NS4)?'<layer name="outer" bgcolor="'+bordcol+'" visibility="hide">' : '<div id="outer" style="position:absolute; top:0px; left:0px; width:'+barwidth+'px; height:'+barheight+'px; visibility:hidden; background-color:'+bordcol+'">';
txt+='<table border="0" cellspacing="0" cellpadding="0"><td width="'+barwidth+'" height="'+barheight+'" align="center">';
if(NS4)txt+='<ilayer width="100%" height="100%"><layer width="100%" height="100%" bgcolor="'+unloadcol+'" top="0" left="0">';
txt+='<table border="0" cellspacing="0" cellpadding="0"><td width="'+barwidth+'" height="'+barheight+'" bgcolor="'+unloadcol+'" align="center"><font color="'+loadcol+'" size="2" face="sans-serif">Pre Loading...</font></td></table>';
if(NS4) txt+='</layer>';
txt+=(NS4)? '<layer name="done" width="100%" height="'+barheight+'" top="0" left="0">' : '<div id="done" style="position:absolute; top:0px; left:0px; width:'+barwidth+'px; height:'+barheight+'px; Z-Index:100">';
txt+='<table border="0" cellspacing="0" cellpadding="0"><td width="'+barwidth+'" height="'+barheight+'" bgcolor="'+loadcol+'" align="center"><font color="'+unloadcol+'" size="2" face="sans-serif">Pre Loading...</font></td></table>';
txt+=(NS4)? '</layer></ilayer>' : '</div>';
txt+='</td></table>';
txt+=(NS4)?'</layer>' : '</div>' ;
document.write(txt);
}//konnte den IE leider nicht einbinden für GetById

if(NS4){
outer=document.outer;
done=document.outer.document.layers[0].document.done;
}
else if(DOM||OP){
outer=document.getElementById('outer');
done=document.getElementById('done');
}
else {
outer=document.all.outer;
done=document.all.done;
}

setpos();

for(i=0;i<image.length;i++){
img[i]=new Image();
img[i].onload = checkload;
img[i].src=image[i];
}

function setpos(){
var ww=(IE||DOM||OP)? document.body.clientWidth : window.innerWidth;
var x=(ww-barwidth)/2;
if(NS4){
outer.moveTo(x,ypos);
outer.visibility="show";
}
else if(IE){
outer.style.left=x+'px';
outer.style.top=ypos+'px';
outer.style.visibility="visible";
}
cplayer(done,0,0,barheight,0);
}

function dispbar(){
cplayer(done, 0, size*count, barheight, 0);
if(count>=image.length)hidebar();
}

function checkload(){
count++;
prozent=Math.round(count/image.length*100);

if (count<=image.length) {

if (DOM||OP) {
var display="<table cellspacing="0" cellpadding="0""><tr><td height="24" width="300" style="position:absolute; top:70px; left:"+(document.body.clientWidth-300)/2+"px; background-color:blue">&nbsp;</td><td height="24" width=""+(prozent*3)+"" style="position:absolute; top:70px; left:"+(document.body.clientWidth-300)/2+"px; background-color:aqua">&nbsp;</td><font style="font-family:sans-serif; font-size:12pt; color:red; position:absolute; top:70px;left:"+(document.body.clientWidth-240)/2+"px">&nbsp;Loading..."+count+"&nbsp;Images..."+prozent+"%</font></tr></table>";
document.getElementById("screen").innerHTML=display;
if(prozent>=100)hidebar();
}
else dispbar();
setTimeout('hidebar()', 10000);//falls der load ausfällt nach 10 sekunden abruch
status='Images'+count+' Pre Load...'+prozent+'%';
} else hidebar();
}

function hidebar(){
if(NS4)outer.visibility="hide";
if(IE)outer.style.visibility="hidden";
status='Pre Load complete!';
imgdone=true;
location.href="welcome.html";//wenn die bilder geladen sind,weiterleiten
}

function cplayer(layer, ct, cr, cb, cl){
if(NS4){
layer.clip.top=ct;
layer.clip.right=cr;
layer.clip.left=cl;
}
if(IE)layer.style.clip='rect('+ct+' '+cr+' '+cb+' '+cl+')';
}

Gruss
Alain
P.S.Falls jemand bessere ideen hat zum SCRIPT(vorallem wegen dem IE),dann ohne hemmungen mitteilen.