May 17, 2008

Image Preloader With Progress Bar Status - Pure Client-Side JavaScript tested in 4 Browsers!

Free Web Hosting, No Ads > CONTRIBUTE > Tutorials
Pages: 1, 2, 3

free web hosting

Image Preloader With Progress Bar Status - Pure Client-Side JavaScript tested in 4 Browsers!

SystemWisdom
Tutorial: Image Preloader with Progress Bar, by Rob J. Secord, B.Sc. (SystemWisdom)


Description:
A Tutorial for a Client-Side Image Preloader with Dynamic Real-Time Progress Bar Indicator written in JavaScript!
Tested to work with 4 Major Internet Browsers: Firefox, MSIE, Netscape, Opera

(Complete sample solution provided at end of tutorial, just put it on your web-server, add your images and go!)


Intended Audience:
Beginner to Intermediate Web Developers.

Although this tutorial will cover some advanced aspects of JavaScript, I will try to explain it all as thoroughly as possible. At the same time, I will keep the functionality basic and leave room for you to expand on it as you see fit.

Assumed knowledge:
-- OOP Concepts such as Classes
-- Arrays, Loops
-- JavaScript Basics
-- Working with *.js files


Background:
Many websites rely on Images for the Graphical User Interface (GUI) of their Web Applications. This is great for visual appeal, but when the site consists of mostly images (both large and small) to make up the entire layout, then your visitors download time ends up taking longer. And as all of us should already know, no one likes to wait too long for a site to load without at least a visual indication of its progress.
On average, people with broadband connections will wait up to 10 seconds for a site to load -- which isn't very much time at all!

Another problem while the site is loading for the visitor, is that they see the site slowly take shape, as single images are downloaded individually and fitted into the screen so as to form the layout. It would be much more appealing if the site were to load all at once, images and text loaded and in place all ready to go!

The solution? An Image Preloader with Progress Bar Status!

Great! But how?


Theory:
Utilizing the Document Object Model (DOM) of HTML with the power of JavaScript, we can access all of our sites images as Objects, giving us access to the Events fired by the Image Objects.

On top of that, when we load an Image in JavaScript via the DOM, we point to the location of the Image via a Uniform Resource Locator (URL) just as we would with regular HTML <IMG> tags. This means that the Image gets loaded into the memory of the visitors computer. Now, when we call for an image in our main page like <img src="img/blah.gif">, the relative Image URL is already loaded, and thus the Image gets displayed immediately.

Now as I mentioned before, when we load an Image via JavaScript and the DOM, we have access to the Events of that Image Object, and to name a few of those events we have:

OnLoad()
OnError()
OnAbort()

Pretty straight-forward really; when the Image is completely loaded the OnLoad() event gets called. If an error occurs while loading the Image the OnError() event gets called. And lastly, if the user (visitor) leaves the page (or closes browser) the OnAbort() event gets called.

In this tutorial we will only need to deal with the OnLoad() event, however, the other events could be of great use, and should be simple enough for you to implement on your own after reading this tutorial. (I will leave a basic code structure for the extra events in the sample at the end of this tutorial, but I will not be explaining them in great detail. That could be left open for discussion!)

The main purpose of implementing the OnLoad() event is to keep track of our loaded images so we can display a Real-Time Progress Bar to our users. The idea here is to keep a counter of how many images have been loaded, so we know our progress. (Hint: You could also track how many Images fail to load via the OnError() event!)

Finally, we have to display that progress on the screen, which can be solved with the use of Span Tags and CSS! In this tutorial I will simply lay out 10 boxes (via Span Tags) each with a Grey BackGround Style, and as the progress increases, I will change the style of each consecutive box to a Blue BackGround, giving a visual appearance of a Progress Bar!

I hope you were able to follow along thus far, we are going to tackle the actual code next! biggrin.gif


Implementation:
All right! We are going to start on the last section of this tutorial where we actually get to build something! (If you feel daunted by the length of this tutorial at this point, know that the longest section lies yet ahead! Fear not, brave reader!)

Now, I am going to take you through 3 stages in building our Image Preloader with Progress Bar:

1) Writing the Preloader class in JavaScript -- This is the core of our preloader, and where most of the theory from above takes place;
2) Writing the Progress Bar Page -- This is a simple HTML page used soley to display the Progress Bar to our visitors;
3) Putting it all together -- This is where we will implement the Preloader Class into our Progress Bar Page to make it all work!

Due to the 'intertwined' nature of the code, it will be difficult to explain, and you may benefit from reading parts of this section more than once after having read it all. Try to remember any parts that confuse you, and come back to it later, after reading more of the tutorial.



Writing the Preloader class in JavaScript:
We start off by making a new file called 'ipreload.js'. This will be our Image Preloader Class File which will contain a single class declaration. If you have never worked with Classes in JavaScript before, they may seem odd at first. This is due to the fact that JavaScript (ECMAScript) lacks full support for user-defined class types. sad.gif But fret not, my friend! I shall explain them anyway! biggrin.gif

(Note: If you already understand classes in JS, you may safely skip the following quoted section)
QUOTE("On the Subject of JavaScript Classes")
Classes in JavaScript are declared using the 'function' keyword. Weird? This is because the declaration is used as both the Declaration and the Constructor. All of your member variables to be used in your class should be declared within this Declaration/Constructor using the keyword 'this' followed immedialtely by a dot and then the variable name.  Assignment operations may also take place within the statement.  A full example thus far:
CODE

function MyClass()
{
   this.MyVariable = 0;
}


Now, to add methods (or member functions) to the class gets weirder with the involvment of the 'prototype' keyword, as in:
CODE

MyClass.prototype.MyFunction = function()
{
   // Access to the member variable:
   this.MyVariable = 1;
}


There you go, a working Class in JavaScript with 1 Member Variable, and 1 Member Function!
Now to instantiate an object of that class is as simple as calling the Constructor function with the 'new' keyword, and assigning its value to a variable, as in:
CODE

var MyObject = new MyClass();

// Call the member function:
MyObject.MyFunction();


I hope you were able understood that, please mind my briefness as this is not a tutorial on Classes in JavaScript (that could be an entire tutorial of its own!)


Okay, moving on.. Now that we understand classes in JavaScript, we will begin with our 'ImagePreload' Class. I will first show you the completed class and then I will explain how it works, this way you will have reference to what I am writing about.

File = ipreload.js:
CODE

<!--

function ImagePreload( p_aImages, p_pfnPercent, p_pfnFinished )
{  
   // Call-back functions
   this.m_pfnPercent = p_pfnPercent;
   this.m_pfnFinished = p_pfnFinished;

   // Class Member Vars
   this.m_nLoaded = 0;
   this.m_nProcessed = 0;
   this.m_aImages = new Array;
   this.m_nICount = p_aImages.length;

   // Preload Array of Images
   for( var i = 0; i < p_aImages.length; i++ )
       this.Preload( p_aImages[i] );
}

ImagePreload.prototype.Preload = function( p_oImage )
{  
   var oImage = new Image;
   this.m_aImages.push( oImage );

   oImage.onload = ImagePreload.prototype.OnLoad;

   oImage.oImagePreload = this;  // Give the Image Object a Reference to our Class..
   oImage.bLoaded = false;       // Custom value added to track state
   oImage.source = p_oImage;     // Original Source Path to Image (for later use)
   oImage.src = p_oImage;        // Image Object Source Path
}

ImagePreload.prototype.OnComplete = function()
{  
   this.m_nProcessed++;
   if ( this.m_nProcessed == this.m_nICount )
       this.m_pfnFinished();
   else
       this.m_pfnPercent( Math.round( (this.m_nProcessed / this.m_nICount) * 10 ) );
}

ImagePreload.prototype.OnLoad = function()
{  
   // 'this' pointer points to oImage Object because this function was previously assigned
   // as an event-handler for the oImage Object.
   this.bLoaded = true;
   this.oImagePreload.m_nLoaded++; // Access our Class with the Reference assigned previously..
   this.oImagePreload.OnComplete();
}

//-->


Okay, we have a class called 'ImagePreload' whose constuctor takes 3 parameters, namely p_aImages, p_pfnPercent and p_pfnFinished respectively.
The first parameter 'p_aImages' is an Array of Strings which holds the URL of all of the images we want to Preload. We will build this array outside of this class later on, and pass it into the class when we instantiate an object of the class.
The second and third parameters are actually Functions (or more precisely, Function Pointers) that we want our class to have access to without being part of the class itself. We will deal more with these later.

Now looking into the Constructor function for our class we will see that the last two parameters are being assigned to Member Variables of the class, so that they are stored locally and are available for the class to call as functions later on. They are commented as "Call-Back functions", and that is exactly what they are: They "Call-Back" to the code that "Called" our Class' Constructor/Member Functions. More over, they can be considered Events that are raised by our class. I will elaborate on this further later in this tutorial. Moving on..

Next you will see some more Member Variables being declared within the class, namely: m_nLoaded, m_nProcessed, m_aImages and m_nICount. I will try to explain them each briefly, yet adequately each in a single paragraph of their own;

Since our class will keep a counter for all of the Images it loads, we will need a Member Variable to hold that counter, starting at 0. The 'm_nLoaded' Member Variable serves this purpose. After each successfully loaded image, 'm_nLoaded' will be incremented by 1.

Our class will also keep a counter for the number of Processed Images (meaning the images that our Progress Bar has accounted for) to calculate the Overall Progress. The 'm_nProcessed' Member Variable serves this purpose. This should be unaffected by Image Load Failures from the OnError() events (Be sure to note that if you plan to add error handling to this class).

Our class will also be storing the Image Objects in Memory on the visitors machine, so that they are considered "Preloaded", and we will do this by creating an Array, and adding the Image Objects to the Array as the images are loaded. The 'm_aImages' Member Variable serves this purpose. Note that this Member variable starts with 'm_' unlike the parameter with the same name, which starts with 'p_'.

Finally, our class will need to know the total number of images it is preloading in order to compute a progress, and yes, the 'm_nICount' Member Variable serves this purpose! We can get this value from the Arrays 'length' property, which returns the number of elements in the array.

Okay, so that should explain most of the Constructor function to you, and now we will look at the last part of the code in the constructor function.. Hopefully, you've kept up with me and the reference code above, if not here is the part I am refering to next:
CODE

   // Preload Array of Images
   for( var i = 0; i < p_aImages.length; i++ )
       this.Preload( p_aImages[i] );


This is a basic FOR loop which we will use to walk through the Array of Image URLs that were passed into the function as the First Parameter. We will then pass each individual URL string to our class' Preload() Member Function which handles the actual "Preloading" of each Image Object.
As you can see by now, as soon as you Instantiate the ImagePreload Object passing it the Array of Image URLs, the preload process will start immediately, and within seconds (hopefully) all of your Images will be preloaded!

But wait! What about the progress bar?!
Since the ImagePreload class will be taking care of loading all of those images, how will the Progress Bar know what's going on?

This is solved by those two "Call-Back" functions I mentioned earlier. Since the Progress Bar itself will be completely seperate code with a seperate responsibility, it will have two functions of its own. One function will update the Progress Bar Display, and the other function will redirect to the main page of your site when the preloading is done!

Now, as I mentioned earlier, the two "Call-Back" functions were assigned to Member Variables which means that any function in our class can now call either of those two functions whenever it needs to. Basically, we will use them as Events, so that everytime an image is loaded, the progress is calculated and the Event (Call-Back Function) is called, sending back the current progress! Now since those functions actually belong to (and are coded in) the Progress Bar, then they will get called and Instantly Update the Progress or Redirect the Page Accordingly!

Hopefully that made sense to you, either way, I shall explain it in more detail.
In reference to the code above, we should now be looking at the Preload() function declared as:
CODE

ImagePreload.prototype.Preload = function( p_oImage )


Recall that this function is executed in the FOR loop in the Constructor of our Class, and is being passed a URL string of the Image to Preload. Looking into the function we notice the first two statements, the first line just instantiates an Image Object (which is part of JavaScript) and the second line adds that Image Object into our Array of Image Objects which we had declared earlier in the Constructor. Memory space is now reserved for this image on the visitors computer!

Next, we see a see a statement dealing with the OnLoad() event of the Image object:
CODE

oImage.onload = ImagePreload.prototype.OnLoad;


We are basically telling the Image Object to Call a Member Function in our class when the Image is loaded, and our Member Function will be responsible for tracking the progress.
But there is one tricky thing to note about this assignment; the 'ImagePreload.prototype.OnLoad' function now "belongs" to the Image Object, even though the function is implemented in our class. The important point is that the 'this' keyword within our 'ImagePreload.prototype.OnLoad' Member Function will not point to our 'ImagePreload' Object Instance, but rather the Image Object Instance. (Crude Analogy: this is not this anymore, it is that! tongue.gif)
This may seem very confusing at first, but don't give up! It makes sense! Besides, you don't have to understand it, just know that it works and how to use it!

Now if you didn't understand what I just wrote, then the next statement won't make much sense to you:
CODE

oImage.oImagePreload = this;  // Give the Image Object a Reference to our Class..


Basically, we want the Image Object to have access to our Class. This is used to access the Call-Back functions in our class from within the OnLoad() function which now belongs to the Image Object. Make sense? I hope so, I don't know how else to explain it! sad.gif But don't fret my friend, read further! Maybe it will clear up for you later!)

The next few statements are much simpler:
CODE

   oImage.bLoaded = false;       // Custom value added to track state
   oImage.source = p_oImage;     // Original Source Path to Image (for later use)
   oImage.src = p_oImage;        // Image Object Source Path


The first is just a simple boolean flag to indicate whether the Image Object has been loaded or not, which is set to False by default.
The next two lines are pretty much the same, except that the first one is a custom variable and the second one is actually an Image Object Property 'src', much like in HTML <IMG> Tags. When you assign a a URL to this property it will be interpreted immediately and the actual image will be loaded into the Memory space we had reserved earlier! This is the load process internally, and when then image is done loading the OnLoad() event gets fired calling our OnLoad() Member Function.
The custom variable 'source' is used for referencing the original path & filename of the image (if you should need to) whenever you need to.

And that is the Preload() function!! Hopefully, you now understand how the actual Preload process works!

We will now move on to the final 2 Member Functions: OnLoad and OnComplete..

CODE

ImagePreload.prototype.OnLoad = function()
{  
   // 'this' pointer points to oImage Object because this function was previously assigned
   // as an event-handler for the oImage Object.
   this.bLoaded = true;
   this.oImagePreload.m_nLoaded++; // Access our Class with the Reference assigned previously..
   this.oImagePreload.OnComplete();
}


Now, since the OnLoad() function belongs to the Image Object, we can directly manipulate the variables we gave it earlier, namely the 'bLoaded' boolean flag. We will set this to true, to indicate that this image object was loaded successfully.
We also need to increment the counter holding the total number of Loaded Images thus far, which is a Member Variable that belongs to the ImagePreload class, and this function doesn't! So, we access the reference we stored earlier as a custom variable in the Image Object. We can now use that reference object to access anything in our ImagePreload class, which the next two statements do; the first of which simple increases the counter, and the second calls our final Member Function 'OnComplete'.

CODE

ImagePreload.prototype.OnComplete = function()
{  
   this.m_nProcessed++;
   if ( this.m_nProcessed == this.m_nICount )
       this.m_pfnFinished();
   else
       this.m_pfnPercent( Math.round( (this.m_nProcessed / this.m_nICount) * 10 ) );
}


This function is pretty simple, it belongs to our ImagePreload class and simply increments the counter of Processed Images. (Note: If the # of Processed Images is not equal to the # of loaded images, then some of your imges fail to load. But the progress will still compute correctly!)

Next it checks to see if it has processed all the required images, and if so it raises the "Finished" event, which tells the Progress Bar code to redirect to the main page. However, if it is not done loading all of the required images, it will raise the "Percent" event, which tells the Progress Bar to update the display according to the Percent Complete!
(The Percentage is rounded to a single digit number from 1-10, but this could easily be changed to suit your needs).

Whew! Take a break! Your done Stage 1 of the Implementation Section! It's pretty much downhill from here! biggrin.gif


Writing the Progress Bar Page:
I am going to keep this part of the tutorial a simple as possible, since it only deals with basic HTML tags, and some simple CSS styles for appearance. This is going to be the GUI of the Progress Bar, and most of you will probably change the appearance of it anyway.

Basically, you just need an empty webpage (preferably no images, otherwise, what's the point of the Preloader?)
So it could look something like this (keeping it simple):

File = index.html:
CODE

<html>
<head>
<style type="text/css"><!--

.OuterBorder
{  border:1px solid #426394;
  padding: 2px 5px 2px 5px;
}
.FullDot
{  border:1px solid #426394;
  background-color:#DAE1EB;
  cursor:default;
}
.EmptyDot
{  border:1px solid #426394;
  background-color:#F3F6FA;
  cursor:default;
}
//--></style>
</head>
<body>

<center>
<table cellpadding="0" cellspacing="0" border="0" class="OuterBorder">
 <tr>
  <td>
     <span id="sDot1" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot2" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot3" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot4" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot5" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot6" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot7" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot8" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot9" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot10" class="EmptyDot">&nbsp;&nbsp;</span>
  </td>
 </tr>
</table>
</center>

</body>
</html>


You'll notice it is just 10 span tags within a bordered table, each span tag representing an 'EmptyDot'. As the progress increases, the 'EmptyDots' will become 'FullDots'.

Well, nothing special there, just some regular HTML/CSS stuff.. So, we move on, to the Final Stage!


Putting it all together:
This stage shouldn't be too tricky either.. First we will have to include or ImagePreload class file into our HTML page, then we will write our 2 functions that will respond to the events raised by our ImagePreload class, as well as a third function to start the whole Loading process rolling! Also, we will add an extra link on the page, that will give the visitor the option to "Skip Preload" and go straight to the main page..

First, including the Preloader, which most of you I assume will be familiar with. Simple JS file including:
CODE

<script type="text/javascript" language="JavaScript" src="ipreload.js"></script>


Now, we want to create 3 more JavaScript functions inside the <HEAD> tag of the web page, as mentioned earlier. I will first show you the completed HTML file, and then like before, I will explain it all to you, with the code as reference:

File = index.html:
CODE

<html>
<head>
<style type="text/css"><!--

.OuterBorder
{  border:1px solid #426394;
  padding: 2px 5px 2px 5px;
}
.FullDot
{  border:1px solid #426394;
  background-color:#DAE1EB;
  cursor:default;
}
.EmptyDot
{  border:1px solid #426394;
  background-color:#F3F6FA;
  cursor:default;
}
//--></style>

<script type="text/javascript" language="JavaScript" src="ipreload.js"></script>

<script type="text/javascript" language="JavaScript"><!--

var g_iStep = 0;

function OnImgUpdate( iProgress )
{  
   if( (iProgress >= 1) && (iProgress <= 10) && (iProgress > g_iStep) )
   {  
       g_iStep++;
       var oSpan = document.getElementById( "sDot" + iProgress + "" );
       oSpan.className = 'FullDot';
   }
}

function OnCompletion()
{  
   document.location.replace('main.html');
}

function StartPreload()
{
   var szImages = new Array( "image1.gif", "image2.jpg", "image3.png", "etc..." );

   // Execute Image Preloader
   var oPreload = new ImagePreload( szImages, OnImgUpdate, OnCompletion );
}

--></script>

</head>
<body onload="StartPreload()">

<center>
<table cellpadding="0" cellspacing="0" border="0" class="OuterBorder">
 <tr>
  <td>
     <span id="sDot1" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot2" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot3" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot4" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot5" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot6" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot7" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot8" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot9" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot10" class="EmptyDot">&nbsp;&nbsp;</span>
  </td>
 </tr>
</table>
</center>

</body>
</html>


Now, the first thing you'll notice, is that there is not much left to do! Yay! I'm exhausted from typing! Okay, going back on track now...

You could seperate the CSS and put it in an external *.css file if you prefer, but I kept this tutorial simple, with the use of only 2 files (plus the rest of your website).

The first thing to note in the newely added JavaScript code block is:
CODE

var g_iStep = 0;


This is a global variable that needs to maintain its value, hence it is declared outside of any specific code block. The reason for this variable is simple; The Progress Bar display in this tutorial only has 10 steps, but you could have 50+/- images. Since the Update Event gets called for every loaded image, then it is unnesseccary to Update the progress bar with every image, instead we track when the Percent value changes, store the new value in the 'g_iStep' variable and Update the display only if the 'g_iStep' variable has increased!

This all takes place in the 'OnImgUpdate' function:
CODE

function OnImgUpdate( iProgress )
{  
   if( (iProgress >= 1) && (iProgress <= 10) && (iProgress > g_iStep) )
   {  
       g_iStep++;
       var oSpan = document.getElementById( "sDot" + iProgress + "" );
       oSpan.className = 'FullDot';
   }
}


Should be pretty straight-forward from what I wrote above. Worth noting though, is the 'oSpan' variable, which refers to one of the HTML <SPAN> tags in the DOM that make up the Progress Bar Display. We can get access to this Span Tag as an Object via the 'document.getElementById()' function which is part of JavaScript. All we need to do, is tell the function the ID of the Span Tag, which we have named successively ranging from "sDot1" to "sDot10". Each ID corresponds to a Progress Interval. Now that we have access to the Span Tag Object, we can change its Style via the 'ClassName' property, which we then change to 'FullDot' so as to indicate a Full Dot, and Progress on the Progress Bar!

Well, that takes care of the Progress Bar actually moving! Now we have to Redirect to the Main page of your site once it is complete. Our ImagePreload class will take care of raising the Event when all of the images are loaded, we just need to do something now when that event occurs.

This will happen in our 'OnCompletion()' function:
CODE

function OnCompletion()
{  
   document.location.replace('main.html');
}


Pretty simple really, if you understand the Basics of Javascript. We just Redirect to the Main page of your site (assuming the page is called 'main.html', if not point it to your page). Also, the replace() function has the added benefit of removing the preloader from the history, so people don't click there Back button and go to a Preloader page!


And finally, where my tutorial draws near to its conclusion, we put it all together in one Simple function:
CODE

function StartPreload()
{
   var szImages = new Array( "image1.gif", "image2.jpg", "image3.png", "etc..." );

   // Execute Image Preloader
   var oPreload = new ImagePreload( szImages, OnImgUpdate, OnCompletion );
}


Now the first thing you will notice, is the Array of Image URLs, these are "Relative" URLs and should point to the actual image files on your webserver that you wish to preload. This script will not work "As Is" unless you point to Your image files in the Array.

How ever you build that Array of images is up to you, I personally use PHP to recurse through my /img/ directory making a list of all the Image path/filenames it finds, and then outputs that list into the Preloader Pages Image URL Array above. That would be a tutorial of it's own, so I will save going into detail about that for another day!

Next, is the MAin line of execution for our Preloader script.
CODE

var oPreload = new ImagePreload( szImages, OnImgUpdate, OnCompletion );


In this one line is where we Instantiate a new 'ImagePreload' Object, passing to its Constructor 3 parameters: the Array of Image URLs, the 'Update' Event Function Pointer and the 'Finished' Event Function Pointer which starts the whole Preloading process in motion!

The 'StartPreload' function should be called as soon as the Preload Page loads, so we will call it in the onload event handler of the Body Tag:
CODE

<body onload="StartPreload()">



And there you have it! An Image Preloader with Progress Bar Status in JavaScript!

So, as the End-Result, we have the 2 completed Files (with the extra stuff I mentioned left in):

File = ipreload.js:
CODE

<!--

function ImagePreload( p_aImages, p_pfnPercent, p_pfnFinished )
{   // Call-back routines
   this.m_pfnPercent = p_pfnPercent;
   this.m_pfnFinished = p_pfnFinished;

   // Class Member Vars
   this.m_nLoaded = 0;
   this.m_nProcessed = 0;
   this.m_aImages = new Array;
   this.m_nICount = p_aImages.length;

   // Preload Array of Images
   for( var i = 0; i < p_aImages.length; i++ )
       this.Preload( p_aImages[i] );
}

ImagePreload.prototype.Preload = function( p_oImage )
{   var oImage = new Image;
   this.m_aImages.push( oImage );

   oImage.onload = ImagePreload.prototype.OnLoad;
   oImage.onerror = ImagePreload.prototype.OnError;
   oImage.onabort = ImagePreload.prototype.OnAbort;

   oImage.oImagePreload = this;
   oImage.bLoaded = false;
   oImage.source = p_oImage;
   oImage.src = p_oImage;
}

ImagePreload.prototype.OnComplete = function()
{   this.m_nProcessed++;
   if ( this.m_nProcessed == this.m_nICount )
       this.m_pfnFinished();
   else
       this.m_pfnPercent( Math.round( (this.m_nProcessed / this.m_nICount) * 10 ) );
}

ImagePreload.prototype.OnLoad = function()
{   // 'this' pointer points to oImage Object
   this.bLoaded = true;
   this.oImagePreload.m_nLoaded++;
   this.oImagePreload.OnComplete();
}

ImagePreload.prototype.OnError = function()
{   // 'this' pointer points to oImage Object
   this.bError = true;
   this.oImagePreload.OnComplete();
}

ImagePreload.prototype.OnAbort = function()
{   // 'this' pointer points to oImage Object
   this.bAbort = true;
   this.oImagePreload.OnComplete();
}

//-->



File = index.html:
CODE

<html>
<head>
<style type="text/css"><!--

.OuterBorder
{  border:1px solid #426394;
  padding: 2px 5px 2px 5px;
}
.FullDot
{  border:1px solid #426394;
  background-color:#DAE1EB;
  cursor:default;
}
.EmptyDot
{  border:1px solid #426394;
  background-color:#F3F6FA;
  cursor:default;
}
//--></style>

<script type="text/javascript" language="JavaScript" src="ipreload.js"></script>

<script type="text/javascript" language="JavaScript"><!--

var g_iStep = 0;

function OnImgUpdate( iProgress )
{  
   if( (iProgress >= 1) && (iProgress <= 10) && (iProgress > g_iStep) )
   {  
       g_iStep++;
       var oSpan = document.getElementById( "sDot" + iProgress + "" );
       oSpan.className = 'FullDot';
   }
}

function OnCompletion()
{  
   document.location.replace('main.html');
}

function StartPreload()
{
   var szImages = new Array( "image1.gif", "image2.jpg", "image3.png", "etc..." );

   // Execute Image Preloader
   var oPreload = new ImagePreload( szImages, OnImgUpdate, OnCompletion );
}

--></script>

</head>
<body onload="StartPreload()">

<center>
<table cellpadding="0" cellspacing="0" border="0" class="OuterBorder">
 <tr>
  <td>
     <span id="sDot1" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot2" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot3" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot4" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot5" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot6" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot7" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot8" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot9" class="EmptyDot">&nbsp;&nbsp;</span>&nbsp;
     <span id="sDot10" class="EmptyDot">&nbsp;&nbsp;</span>
  </td>
 </tr>
</table>
</center>

</body>
</html>



Conclusion:

Well, I hope that you have learned something from this tutorial, and maybe even use such a preloader in your web sites!

Also note, that this Preloader won't work well with less than 10 images, but in that case you don't need a preloader like this one!

Please feel free to comment on this tutorial, if you noticed anything wrong or out of place in this tutorial, please don't hesitate to mention it!
I am interested in all feedback really, I'm curious about what you think of my writing, tutorial, methods used, code, etc.. Thanks!

I would have a working example to show, but my web host went down a while back. Sorry!

Read part 2 of this tutorial entitled "Extending the Image Preloader with PHP4"

Notice from BuffaloHELP:
Edited per request.

 

 

 


Reply

snlildude87
Oh. My. Gosh. How long did it take you to write that?!

Back on topic. I saw this on a site before, but I was too lazy to check the source to see how they preloaded their images. Anyways, I'm going to try this out on the weekends when I have more time.

Good stuff man! Keep it up smile.gif

Reply

SystemWisdom
Was it Mercury-Admin? I had hosting with them a while back, but they have gone down now, and I had originally posted the same tutorial there (that was the first time I posted it). Unfortunately for me, when their servers went down, I lost the original tutorial I posted, and I had to rewrite this one again from scratch.. Took about 2.5 hours today! biggrin.gif

Did you read it? What did you think?

Reply

snlildude87
QUOTE(SystemWisdom @ May 3 2005, 09:51 PM)
Did you read it?  What did you think?
*

To be honest, no, I did not read it, but I will read it over the weekend or some other time when I have...time. Too much school work right now laugh.gif

Reply

BuffaloHELP
I don't do codings well but to a novice user such as myself, would it not be easier to make a file called "preload.js" with the following code?

CODE
img1 = new Image();
img1.src = "images/nameofIMAGE1.jpg";

img2 = new Image();
img2.src = "images/nameofIMAGE2.jpg";

img3 = new Image();
img3.src = "images/nameofIMAGE3.jpg";

img4 = new Image();
img4.src = "images/nameofIMAGE4.jpg";

img5 = new Image();
img5.src = "images/nameofIMAGE5.jpg";

And just call "preload.js" from your <BODY> tag just like any other JavaScripts? This not only works with any amount of array, short or long, but I guess I see the disadvantage if you have growing number of images. But it's easier for me to edit on this script.

Reply

SystemWisdom
Technically, that is exactly what my code is doing, but I wrapped it in a class so as to provide Events used for generating a Progress Bar for its display.
The code you posted will not give any visual indication of its progress, which was one of the problems solved by my tutorial.

It comes into play mainly when you have alot of images; with your suggested method the user will see nothing for a while until all images are loaded, whereas with my suggested method they will see a Dynamic Real-Time Progress Bar.

Either way, both methods work, and it boils down to opinion really.. Which method do you want to use? It is up to you! biggrin.gif

Reply

snlildude87
One question: do you have a demo of this - a web page where you used all this, so we all can test it?

Reply

SystemWisdom
I did, but my previous hosting (at Mercury-Admin.com) has gone down, so my site went with it... I have it backed up of course, and when I get new hosting I will put the site back online, which includes a working sample suited to my site, which loads approx. 60+ images.. (Although a portion of it is in PHP to dynamically load all the image URLs into the array)

The tutorial code is however, all Client-side Javascript + HTML really, so you could test it out rather quickly if you have say 10 or more images you could use to make a mock-up test environment..

As soon as I get new hosting and get my site back online, I will post a sample link to it.. Sorry for not having a Demo though, I know they are always nice!

Also, I will write another tutorial shortly, about the PHP portion I mentioned above..

Reply

BuffaloHELP
QUOTE(SystemWisdom @ May 3 2005, 11:16 PM)
Technically, that is exactly what my code is doing, but I wrapped it in a class so as to provide Events used for generating a Progress Bar for its display.
The code you posted will not give any visual indication of its progress, which was one of the problems solved by my tutorial.

It comes into play mainly when you have alot of images; with your suggested method the user will see nothing for a while until all images are loaded, whereas with my suggested method they will see a Dynamic Real-Time Progress Bar.

Either way, both methods work, and it boils down to opinion really.. Which method do you want to use? It is up to you!  biggrin.gif
*



AH! Well, since my site has one main index with two links I have my preload.js called in index.htm. And when the visitor decides to choose, let's say door 1 or door 2, the images are already preloaded before the visitation. I made it so for the simple factor of surfing pleasure. And since my graphics and images were small sized that I preloaded the entire image content even before any visitor views that page. It's like instant load. Therefore I personally would not need the status bar showing what images are being loaded. But now that you mention it my coding is very elementary and does not tell me what is going on. I am going to utilize your coding for my next project. Thank you for your post.

CODE

function PreloadImages()
{ if (document.images) { var imgFiles = PreloadImages.arguments; var preloadArray = new Array();
for (var i=0; i<imgFiles.length; i++) { preloadArray[i] = new Image; preloadArray[i].src = "icons/" + imgFiles[i] + ".gif"; } } }
PreloadImages(img#1, img#2, img#3, etc);


This was one of the codes I found on the web. Interesting condensation.

 

 

 


Reply

NeXDesigns
very well put together tutorial, a bit long, but the longer the better, that way you can understand it all.
i am going to have to try this sometime soon, it looks quite useful. thanks

Reply

Latest Entries

leoncreations
Great and lengthy tutorial there! I managed to read most of it and found it easy to understand and useful for implementing on my own site. Though a condensation of the tutorial or the codes are welcomed. By the way, how would you do it if i want a visitor to view a video or a advertisement of my site while waiting for the site to finish loading?

Reply

Blessed
Greetings wow m8 thats a nice tutorial man

thanx
this can sure help me a lot whit some things..

i like to see more of your tutorials..


Thanx SystemWisdom

Reply

delivi
wow great tutorial,

I needed this functionality a long time before, but never tried to do it. Thanks for sharing this tutorial.

I'd prefer preloading images using CSS rather than Javascript, just for the crooss browser compatability.

Reply

Sprnknwn
Oh, this is a very interesting code, yet really long tongue.gif I'll try to give it a look patiently this weekend and see if I can follow all the steps.

Thank you for sharing it.

Reply

Riton
Hi

In fact, the problem is that Safari seems to not support self-reference in javascript class.
The two last variables in ImagePreload.prototype.OnLoad are marked as "undefined".

For those who wants to debug in Safari with MacOS, type "defaults write com.apple.Safari IncludeDebugMenu 1" on a terminal and then restart Safari. A "debug" menu will be present on the top of the screen.

I think it's a safari bug, but it should exists a workaround.

Regards,
Riton

QUOTE(SystemWisdom @ Jun 13 2005, 02:42 AM) *
I haven't figured it out yet sad.gif

Mac confuses me tongue.gif

Do you know any Javascript at all? It sounds like a few javascript functions are not being recognized by Safari, amd I am having alot of trouble finding out which ones.. Theoretically, it should work fine, unless Safari browsers haven't followed basic standards for DHTML.. sad.gif

Maybe it has to do with it being on a Mac? Did you test it with IE and Firefox from Mac too, or was that on Windows?

I am almost at the point of resolving to detect the Safari browser on Mac and just skip preloading altogether, so it doesn't cause problems... sad.gif

Well, ima keep looking for an answer, wish me luck! tongue.gif


Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Pages: 1, 2, 3
Recent Queries:-
  1. free css progress bar - 0.44 hr back.
  2. mootools background image preload - 0.65 hr back.
  3. detecting when page and image are fuly loaded - 0.95 hr back.
  4. javascript vertical progressbar - 3.38 hr back.
  5. javascript load bar - 6.80 hr back.
  6. preload image (with progress bar) - 8.29 hr back.
  7. downloading progress bar image - 10.12 hr back.
Similar Topics

Keywords : image, preloader, progress, bar, status, pure, client, side, javascript, tested, 4, browsers

  1. Make A Moderately-secure Password System Using Javascript
    using file redirection to hide the password. (2)
  2. Simple Javascript And Password System
    How to protect your pages with password (5)
    The quickest way to get a password protection system up and running is to use a Prompt box in
    JavaScript that has a title like "Enter your Email Address". Only you and the relevant users know
    what the password should be, could even be one each, that can be sorted out at the next page then
    pass the "input" directly through the url by changing the .href, like
    http://www.iSource.net.nz/users/?leTmeIn= The page that then processes this should also check for
    the referring page, and three fails from an IP if you like the php (the next page): CODE
    <?php // processdo....
  3. Ftp In Visual Basic 6.0
    Start making your FTP client using VB6 (0)
    Recently, I had a need to make a FTP client, since our webhosting FTP server was kind of exotic, and
    very restrictive, and most of uploads, even though they reach 100% would crash... File would be
    uploaded to a server, but FTP clients just froze upon completion, waiting for the 226 (OK) from FTP
    server... So, I had to make my own, one who would not wait for 226, but instead, watch the file
    pload progress... This tutorial is not fuly complete, in the sense that it does not offer COMPLETE
    FTP client functionality (for example, I ddn't write the code for FTP download, ....
  4. Create A Simple Html Editor With Php And Javascript
    (3)
    Ok, I will teach you how to create a simple HTML editor that runs online with buttons that add HTML
    tags. Before we start: You should have basic knowledge of these languages. HTML/XHTML
    Javascript PHP You will need Ability to use filesystem functions. Chmodding abilities
    Features of Editor Online PHP safe Full HTML support A Few Bad Features Can only create new
    documents or overwrite Fairly unsafe Now we are ready to begin. The PHP Script This will be
    our PHP script that we will use to make the file. Make a file called save.php Here is the....
  5. Background Image Swap Script
    Change a Background Image based on clock time (13)
    Background Image Changer Script To swap the background image from your CSS file according to the
    Server Clock Time. 1.) In your CSS file, add the following rule: CODE body {
        background: url(time.png); } 2.) Create a "folder" named time.png. 3.) Into the
    folder, place three images named morning.png, day.png, night.png. 4.) Also, in the same folder,
    create an index.php file and copy/paste the following script. CODE <?php $hour =
    date('H'); if ($hour < 12 ) {     $image =
    "morning.png"; } ....
  6. Image Rotator Script (another One)
    easy to implement (0)
    In case you haven't noticed, I have a different Avatar display on the Forum each time the page
    is refreshed. /biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif"
    /> For those of you who might want the script to do that, here is the one I am using: HTML
    $filesp = glob('*.png'); if(empty($filesp)){ echo
    'no images found...die br >'; die(); } else{ foreach ($filesp as
    $file) { $img_array[] = trim($file); }....
  7. Mootools - My Favourite Javascript Library
    (3)
    It kind of amazes me that there's not even a mention of the Mootools javascript library
    throughout this whole forum. So here I'll do a brief introduction and a tutorial on how to
    produce the famous accordion effect. MooTools is a compact, modular, Object-Oriented javascript
    framework designed to make writing extensible and compatible code easier and faster. MooTools lets
    you get the job done efficiently and effectively. It is slightly based on the powerful Prototype
    javascript framework , of which Scriptaculous runs on. (But frankly, I dislike Scriptaculou....
  8. Rename The Ms Windows Recycle Bin
    (Tested on Windows XP). (9)
    I realize there is another topic in this section about the recycle bin, but it doesn't mention
    how to rename the recycle bin. Like most other tasks of this nature, accomplishing this will require
    modifying the windows registry. First, open the registry editing tool "regedit" by clicking on
    Start, Run then typing in "regedit" before pressing OK. Screenshot:
    http://img525.imageshack.us/img525/8230/01ay6.jpg In the regedit program you will see a simple
    looking program with a tree structure control in the left side (displays the setting categories) and
    a panel at the....
  9. Javascript Scroll Bar
    A scroll bar for your webpage using javascript (13)
    In this tutorial I will show you how to create two buttons in the bottom left of the screen that,
    when hovered over, will scroll the page. Now to start with, we must create a our buttons, the first
    line will create a div element, or block. Using blocks you can position items anywhere on a page.
    We use the ID property just to let us know what the block is used for, as for the first block, its
    obvious that it contains the vertical buttons and the second two blocks contains the horizontal
    buttons. The style property of the div tag tells the browser how to draw it, in the....
  10. Math Captcha Image Validation
    (1)
    This tutorial will show you how to make a basic math CAPTCHA validtion form. This requires that you
    have the GD library for PHP installed to work. This tutorial requires 2 files, login.php and
    action.php. The first step is to create a sub-folder to store the temporary images, for the
    purposes of this tutorial,this folder should be called images. Now upload a image in there called
    verify.php and chmod just that image(not the folder) to 777 so that image can change as our
    functions generate new images. Ok, after you've done that, we can get to the code: in login.p....
  11. A Simple Php Captcha - Image Validation
    (21)
    OK, I recently had the need to create a PHP CAPTCHA system for a friend, and I am sharing this as a
    tutorial with the good people here at Trap17. I am sure you have all seen a CAPTCHA before (although
    you may not have known what it was called). They are the little codes you often have to enter when
    you register with a site, to make sure you are a person and not an automated script. Some common
    examples look something like this: My system doesn't really do anything as fancy, but I
    think that it is slightly more readable that some of those that get generated. Every....
  12. How To Build A Pure Css Using Online Tools Tutorial (part 4)
    Vertical Nav Menu (0)
    Step 4 Vertical Nav Menu The next step is to add in a basic rollover menu so I bring you to the
    following online tool: Menu Generator Now with this online tool you can not only create
    vertical but also horizontal rollover menus. Since we will be doing a Verticle menu we will keep it
    on that option. Now the next part is deciding if we want it fixed, relative, or absolute. If we
    have learned anything it is insane trying to make a absolute or fixed position work perfectly for
    all three browsers (IE, FF, Opera). So to keep our minds sane we will use relative,....
  13. Simple Scripts In Html And Javascript
    Things like BackgroundColorChanger and so (7)
    like in the topic, here is a description how to change the Backgroundcolor "On The Fly", by klicking
    on a button or radio-box first, we ned the html-and body-tags, create a new html-file on your
    desktop and write the following: QUOTE <script language = "JAVASCRIPT">
    browser interpretation: html - tag means "hey, browser, here comes HTML" in the body-tag you define
    the looking of your site. you can add things like "bgcolor" for the background, "text" for the
    textcolor and link / alink / hlink / vlink to define the linkcolor ( ) the scripttag i....
  14. How To Build A Pure Css Using Online Tools Tutorial (part 2)
    Part 2-Header (3)
    The next step will be to set up our header with a tab menu a search box and a header image. With
    these three parts you will be able to be make a somewhat dynamic header, so it can be seen more and
    not blended within the website and be lost or hard to find within the website. You have to remember
    the website is for other people and not for you, so you have to make it as user friendly as
    possible. Now with the Text with in the image you could say that this could use be used for
    important updates, or a slogan or two, with this your actual images will be a bit smaller in ....
  15. How To Build A Pure Css Using Online Tools Tutorial (part 1)
    Part 1-Core Design (7)
    The use of Online tools to design a complete website Tutorial By Saint-Michael AKA Mike A. On a
    side note will provide all the files for the complete site from each of the parts just in case you
    have problems With this tutorial I will show you how to use specific online tools to create a
    fully functioning website in pure css with little to no JavaScript to be used. Also their will be
    some moderate editing to make everything fit and of course to make sure everything is working like
    it should. The links that you will need to either book mark or save to a file, w....
  16. Image Gallery Tutorial Using Hoverbox
    A php solution to coding the Hoverbox Image Gallery (14)
    As reported in another posting , there is an Image Gallery named Hoverbox from the Sonspring site
    which is a pretty cool display method using CSS to have Thumbnail pictures double their size by
    hovering over them. I liked the css included in the original Tutorial as found on the Sonspring
    site , but I knew there was more than one use for the Hoverbox and took it upon myself to explore
    the use of the Hoverbox on a site I webmaster. One thing that wasn't right was having to
    hardcode the image tags, so the first version I wrote used php to fill the Hoverbox by rea....
  17. How To Control Popups In Ie And Other Browsers.
    (2)
    If you really hate popups - who doesn't - then there is a very easy way to disallow them - no
    need to download anything at all. Let me show you how to control your popups, and not let your
    popups control you. Internet Explorer Users: 1. Under the tools menu, go to popup blocker popup
    menu and turn on IE's popup blocker if it isn't already 2. Again, go to the same menu, but
    go to popup blocker settings 3. Under the filters frame, change the level to high. 4. You will now
    have a popup free browsing experience. If you need to open up a popup on a place such as....
  18. How To Make Image To Highlight When It`s Mouseovered
    (8)
    Place this code between and tags. CODE <script
    language="JavaScript1.2"> <!-- function makevisible(cur,which){
    strength=(which==0)? 1 : 0.2 if (cur.style.MozOpacity)
    cur.style.MozOpacity=strength else if (cur.filters) cur.filters.alpha.opacity=strength*100 }
    // --> </SCRIPT> Place the following code within all of the image tags you'd
    like the effect to be applied. CODE
    style="filter:alpha(opacity=20);-moz-opacity:0.2"
    onMouseover="makevisible(....
  19. Checking For Open Ports From Php
    If you want to check the status of a server at a specific port you can (3)
    Some days ago, i needed to check ports of a server from a webpage, for advising of its status. I
    simply used a great php code that's fsockopen . I'll explain it in the following example:
    (Imagine a file called 'checkports.php', containing the next) CODE <? $address
    =" trap17.com"; //Here you can specify the address you want to check ports $port =
    "80"; //Here you can specify the port you want to check from $address $checkport =
    fsockopen($address, $port, $errnum, $errstr, 2); //The ....
  20. Javascript Framework - A Shortcut Javascript
    a shortcut javascript (3)
    hi, today im going to give you small tutorial how to use `Prototype JavaScript Framework`
    1st you have to download `Prototype JavaScript Framework`library from
    http://prototype.conio.net/ prototype makes easy to using Javascript, ex : when you want to point
    (get) the element from HTML usually we use : CODE
    document.getElementById('elementId') with prototype we use CODE
    $('elementId') , yeah...world getting small..with prototype. example
    we`re going to get value from an element of CODE &#....
  21. Using A Secure File Transfer Client
    A discussion of FTP, FTPS, SCP, and SFTP (0)
    Using a Secure File Transfer Client Almost everyone who creates a web site is faced with
    the problem of getting their files from their local computer to their web server. There are a few
    different protocols (methods) through which to accomplish this, and some have definite advantages
    over others. Here are the major ones, listed loosely in order of increasing security. Note: All
    of the programs recommended in this tutorial are for Windows only. Command line alternatives are
    accessible via the terminal for both Linux and OS X. FTP First a note on using ....
  22. Image Shack Mod
    For Invision Power Board (2)
    Image Shack Mod For Invision Power Board ''These instructions will help you to install
    'ImageShack on your Site' into the reply, quick-reply, and post-new-thread sections of your
    Invision Power Board, thus giving your visitors the ability to upload images directly. After upload,
    they may paste the images directly into their post box.'' CODE These instructions will
    help you to install 'ImageShack on your Site' into the reply, quick-reply, and
    post-new-thread sections of your Invision Power Board, thus giving your visitors the ability ....
  23. Creating A Simple Image Viewer
    Using Visual Basic 2005 Express Edition (3)
    I downloaded Microsoft's Visual Studio Express suite a few months ago, but only recently got
    around to installing it. I have been practising with Visual Basic and making some rather basic
    programs and utilities, but they contain most of the basic concepts. This tutorial will explain how
    to create a basic image viewer, and I will try to explain each step from beginning to end as clear
    as I can. To start you will need: Microsoft Visual Studio About 10-20 minutes free time OK,
    first open up the Visual Basic part of the Studio. I am using the 2005 Express version, so....
  24. Tool Tips Using Only Css To Pop Up The Tool Tip
    No javascript involved! (8)
    Tool Tip Tutorial Example Found Here . Please review before continuing. Nice. And no
    javascript at all to be found. The colours I have used are for demonstration purposes only to show
    you that they are adjustable to suit the background or to contrast against them. Your choice. That
    is a styling issue. It is your site, you decide. The original author's idea was to add
    position:relative to the link, in order to allow the span element inside to position absolutely
    in respect to the parent link. This code has been tested in Ie5.5, IE6, Opera7.11 and M....
  25. Handy Javascript Code Snips
    Ready to Apply in your webpage (5)
    /tongue.gif' border='0' style='vertical-align:middle' alt='tongue.gif' /> Some common things to
    implement in our webpage very frequently are as follows. How to implement all these I am going to
    tell you in this tutorial. Add To Favorite Set As Homepage Go To Top Of Page No Right Click
    Print Page Adding Current Date Adding Current Time Pop-Up Page Creation Closing Window
    Copyright Notice Updation 01. Add To Favorite Someone may be interested in the content of your
    page. Offer him/her to add the page in his/her favorite menu. To do this you have ....
  26. How To Stop Image Hot Linking
    for a selected directory. (17)
    Those of you that don't know what is meant by 'hotlinking', it is when someone directly
    links to an image on your site so it will display on their site. This is what is called
    'bandwidth theft' and being as accounts here have a limit on bandwidth, your bandwidth limit
    could be exceeded by someone else hotlinking to your images. As most users of cPanel will know,
    there is an option to disable hotlinking of images in the "Site Management Tools" section.
    However, this disables hotlinking to all directories, what if you only want to disable hotlinki....
  27. Image Rollovers In Javascript
    A Write-Once, Use-Anywhere Approach (11)
    Tutorial: Image Rollovers w/ Javascript, by Rob J. Secord, B.Sc. (SystemWisdom) See a
    working Sample of this Script! Download a ZIP containing all working files in this
    tutorial! Note: If you are not interested in reading this entire tutorial and/or have a basic
    understanding of the underlying concepts, you may safely skip to the Implementation section to get
    the code! Description : A Dynamic Image Rollover Script tested to work in 4 major internet
    browsers: MSIE, FireFox, Netscape and Opera. Using only Javascript combined with regular HT....
  28. Using An Ftp Client
    (7)
    Using an FTP Client This tutorial applies not only to accessing your Trap17 account, but
    also to any other FTP account you may need to gain access to. Okay the first thing you're
    going to need is an FTP Client. There are a wide variety of FTP Clients with varying features.
    CoreFTP is a free solution and comes with basic features that most FTP Users need. CuteFTP is
    available for a Freeware download, but is well worth the money to buy a license for it. CoreFTP:
    Includes the following features: SFTP (SSH), SSL, TLS, IDN, browser integration, site to sit....
  29. Server Status
    MAke Your own server status in PHP (12)
    My Friend and i made an mmorpg we decided to make a code so the users could tell when the game
    server was running this codoe has many other uses to like monitor a website or w/e you want to do.
    CODE <? $ip = "youriphere"; $port = "yourporthere"; if
    (! $sock = @fsockopen($ip, $port, $num, $error, 5))
    echo '<B><FONT COLOR=red>Offline</b></FONT>'; else{ echo
    '<B><FONT COLOR=lime>Online</b></FONT>'; fclose(....
  30. A Little Introduction To 3d Studio Max
    How to make a simple abstract image (9)
    This tutorial will teach you the basics of making abstract images in 3D studio max. In this example,
    I used a simple sphere, and applied the “Noise” modifier. Then, I applied a transparent, blue,
    plastic-like material to spice up the whole thing. Let’s start. First, make a sphere by selecting
    the “Sphere” button in the “Standard Primitives” section, and draw somewhere in the center of the
    perspective view. We will set the size of the sphere later on. The sphere I made looks like this,
    yours can be different in size and color, but the only thing that is important is to....

    1. Looking for image, preloader, progress, bar, status, pure, client, side, javascript, tested, 4, browsers

Searching Video's for image, preloader, progress, bar, status, pure, client, side, javascript, tested, 4, browsers
Similar
Make A
Moderately-s
ecure
Password
System Using
Javascript -
using file
redirection
to hide the
password.
Simple
Javascript
And Password
System - How
to protect
your pages
with
password
Ftp In
Visual Basic
6.0 - Start
making your
FTP client
using VB6
Create A
Simple Html
Editor With
Php And
Javascript
Background
Image Swap
Script -
Change a
Background
Image based
on clock
time
Image
Rotator
Script
(another
One) - easy
to implement
Mootools -
My Favourite
Javascript
Library
Rename The
Ms Windows
Recycle Bin
- (Tested on
Windows XP).
Javascript
Scroll Bar -
A scroll bar
for your
webpage
using
javascript
Math Captcha
Image
Validation
A Simple Php
Captcha -
Image
Validation
How To Build
A Pure Css
Using Online
Tools
Tutorial
(part 4) -
Vertical Nav
Menu
Simple
Scripts In
Html And
Javascript -
Things like
BackgroundCo
lorChanger
and so
How To Build
A Pure Css
Using Online
Tools
Tutorial
(part 2) -
Part
2-Header
How To Build
A Pure Css
Using Online
Tools
Tutorial
(part 1) -
Part 1-Core
Design
Image
Gallery
Tutorial
Using
Hoverbox - A
php solution
to coding
the Hoverbox
Image
Gallery
How To
Control
Popups In Ie
And Other
Browsers.
How To Make
Image To
Highlight
When It`s
Mouseovered
Checking For
Open Ports
From Php -
If you want
to check the
status of a
server at a
specific
port you can
Javascript
Framework -
A Shortcut
Javascript -
a shortcut
javascript
Using A
Secure File
Transfer
Client - A
discussion
of FTP,
FTPS, SCP,
and SFTP
Image Shack
Mod - For
Invision
Power Board
Creating A
Simple Image
Viewer -
Using Visual
Basic 2005
Express
Edition
Tool Tips
Using Only
Css To Pop
Up The Tool
Tip - No
javascript
involved!
;
Handy
Javascript
Code Snips -
Ready to
Apply in
your webpage
How To Stop
Image Hot
Linking -
for a
selected
directory.
Image
Rollovers In
Javascript -
A
Write-Once,
Use-Anywhere
Approach
Using An Ftp
Client
Server
Status -
MAke Your
own server
status in
PHP
A Little
Introduction
To 3d Studio
Max - How to
make a
simple
abstract
image
advertisement



Image Preloader With Progress Bar Status - Pure Client-Side JavaScript tested in 4 Browsers!



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE