Click to See Complete Forum and Search --> : Need help with redirecting ...


karl
09-18-2003, 01:45 PM
Hello ! I´m stuck ... I got this preload images with progressbar script and now I want to redirect to a another page after script has preloaded the images.

The script is listed below. If someone could give me a code snippet that would make my page redirect it would be great !

I´m not to mutch of a coder, so thanks for any help.

<script language="JavaScript">

/*
Progress Bar
Copyright Eddie Traversa (nirvana.media3.net)
To add more shock to your site, visit www.DHTML Shock.com
*/

//PUT THE NAMES OF ALL YOUR IMAGES IN THE ARRAY BELOW.
var locationAfterPreload = "startpage2.htm"
var imagenames=new Array('images/mainpicture1.jpg','images/mainpicture1.jpg','images/mainpicture1.jpg','images/mainpicture3.jpg','images/mainpicture4.jpg','images/mainpicture5.jpg','images/mainpicture6.jpg','images/mainpicture7.jpg','images/mainpicture9.jpg','images/mainpicture10.jpg');
var yposition=120; //POSITION OF LOAD BAR FROM TOP OF WINDOW, IN PIXELS
var isNS=(document.layers);
var _all = (isNS) ? 'outer.document.' : 'all.' ;
var _style = (isNS) ? '' : '.style';
var _visible = (isNS) ? 'show' : 'visible' ;
var _hidden = (isNS) ? 'hide' : 'hidden' ;
var blocksize=Math.ceil(250/imagenames.length);
barwidth=imagenames.length*blocksize;
var images=new Array();
var loaded=0, txt='';

function resize(){
if(isNS){
document.outer.moveTo( window.innerWidth/2-barwidth/2 , yposition );
}else{
document.all.outer.style.pixelLeft=document.body.clientWidth/2-barwidth/2;
document.all.outer.style.pixelTop=yposition;
}}

txt+=(isNS)? '<layer name="outer" height="22" bgcolor="lightgrey" top="'+yposition+'" left="'+(window.innerWidth/2-barwidth/2)+'" width="'+barwidth+'" visibility="visible">' : '<div id="outer" style="position:absolute; left:'+(document.body.clientWidth/2-barwidth/2)+'; top:'+yposition+'; height:22px; background-color:lightgrey; width:'+barwidth+'px; visibility:visible;">';
txt+=(isNS)? '<layer z-index="2" width="'+barwidth+'" height="22" ><font point-size="12"><center>Images loading...</center></font></layer>' : '<div style="position:absolute; text-align:center; height:22px; width:'+barwidth+'px; z-index:100; font-size:14px; ">Images loading...</div>';
txt+=(isNS)? '<layer z-index="1" name="prog" height="22" bgcolor="lightseagreen" width="0"></layer>' : '<div id="prog" style="position:absolute; height:22px; background-color:lightseagreen; width:0px"></div>';
txt+=(isNS)? '</layer>' : '</div>';
document.write(txt);

resize();

function dispbars(){
loaded++;
if(isNS){
document.outer.document.prog.clip.width=blocksize*loaded;
}else{
document.all.prog.style.width=blocksize*loaded;
}
if(loaded>=imagenames.length){
setTimeout('(isNS)?document.outer.visibility="hide":document.all.outer.style.visibility="hidden";', 800);
}}

function loadimages(){
for(n=0;n<imagenames.length;n++){
images[n]=new Image();
images[n].src=imagenames[n];
checkload(n);
}}

function checkload(index){
(images[index].complete)? dispbars() : setTimeout('checkload('+index+')', 500);
}


window.onload=loadimages;
window.onresize=resize;
</script>

Charles
09-18-2003, 01:51 PM
I posted a working example in response to your previous request (http://forums.webdeveloper.com/showthread.php?s=&threadid=17726). Scrap what you have and start working with what I posted.