Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > can u help me with my preloader code?

Reply
Thread Tools

can u help me with my preloader code?

 
 
white lightning
Guest
Posts: n/a
 
      09-29-2007
Below is a simple preloader code I have... What I want to do is once
the images have completed preloading, the "Loading Images..." text
must disappear. I am not able to do it.

<html>
<head>
<title>Preloader</title>
</head>

<body>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam
nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat
volutpat.</p>

<div align="center">
<script type="text/javascript">
var imagenames=new Array('http://tbn0.google.com/images?
q=tbn:_Mg6ZYPbkBTWYM:http://www.sat.dundee.ac.uk/jpg/20020131-1205-
large.jpg' , 'http://tbn0.google.com/images?
q=tbn:UhAhRmP9ngqNoM:http://www.ari.uni-heidelberg.de/gaia/gallery/GR/
gr0283-01.artistic-Gaia-Galaxy-large.jpg');

var imagesdone=false;
var loaded=0, preloader, images=new Array();
var txt ='<p id="preloader" style="position:relative; background-
color:#aa00dd; color:#fff; font-size:12px; line-height:25px; vertical-
align:middle; width:300px; text-align:center; font-
family:Arial;">Loading Images...</p>';
document.write(txt);

function loadimages(){
preloader=document.getElementById('preloader');
for(n=0; n < imagenames.length; n++){
images[n]=new Image();
images[n].src=imagenames[n];
setTimeout("checkload('+n+')" ,n*100);
}
}

function dispbars(){
loaded++;
if(loaded >= imagenames.length) setTimeout('hidepreloader()',
800);
}

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

function hidepreloader(){
preloader.style.visibility="hidden";
imagesdone=true;
}
loadimages();
</script>
</div>

<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam
nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat
volutpat.</p>

</body>
</html>

 
Reply With Quote
 
 
 
 
white lightning
Guest
Posts: n/a
 
      09-29-2007
On Sep 29, 1:58 pm, Randy Webb <HikksNotAtH...@aol.com> wrote:
> white lightning said the following on 9/28/2007 11:47 PM:
>
> > Below is a simple preloader code I have... What I want to do is once
> > the images have completed preloading, the "Loading Images..." text
> > must disappear. I am not able to do it.

>
> You obviously are not able to read, understand, and appreciate the
> advice already given to you about this question. What is to make anyone
> believe your attitude will change now if someone spends the time to
> explain everything that is wrong with your code, how to fix it, and then
> have you post the same question again tomorrow?
>


If you find my question irritating, you do not have to reply... I can
ask whatever I want to ask.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Asynchronous Image PreLoader? jj ASP .Net 3 01-20-2009 09:20 PM
Firefox Preloader R Hickey Firefox 1 12-27-2005 02:16 PM
Firefox Preloader problem R Hickey Firefox 0 09-14-2005 03:42 PM
Mozilla Preloader wc Firefox 3 06-17-2005 05:29 PM
Firefox Preloader & FF 1.04 RogerB Firefox 0 05-13-2005 03:38 AM



Advertisments