Preloader XHTML JavaScript version 2.0.3
Here is a "preloader" that will load your pages before displaying the content. This "preloader" displays an image animated gif during loading with a white background.
Here is an example of what it can give, I would advice not to use this script if you used the "CSS Reset". And do not use a tag "DIV" General "CSS" using the position "relative" to all
Here's the Javascript code on this preloader.
/ / You can change the velocity (speed) (1 == very fast) / / You can change the quality of the transition (1 == best) / / Transition is more quality, more speed slowed and should be increased ; var speed = 10; ; var transition = 10; / / Size of animated GIF preloader ; var GIFpreloadLargeur = 20; ; var GIFpreloadHauteur = 20; ; var timer = 0; ; var opacity = 100; opacity function () { opacity = opacity - transition; ( "preloader" ) . style ; var object = document. getElementById ("preloader"). style; opaciT / 100 ) ; object. opacity = (opacity / 100); opaciT / 100 ) ; object. MozOpacity = (opacity / 100); opaciT / 100 ) ; object. KhtmlOpacity = (opacity / 100); + opaciT + ")" ; object. filter = "alpha (opacity =" + opacity + ")"; opaciT <= 0 ) if (opacity <= 0) { "preloader" ) . style . visibility = "hidden" ; document. getElementById ("preloader"). style. visibility = "hidden"; ; clearInterval (timer); } } function preload () { document. getElementById ) if (document getElementById) { "preloadIMG" ) . style . visibility = "hidden" ; document. getElementById ("preloadIMG"). style. visibility = "hidden"; ,speed ) ; timer = setInterval ("opacity ()", speed); } else { document. layers ) if (document layers) { = "hidden" ; document. preloadIMG. visibility = "hidden"; ,speed ) ; timer = setInterval ("opacity ()", speed); } else { . style . visibility = "hidden" ; document. all. preloadIMG. style. visibility = "hidden"; ,speed ) ; timer = setInterval ("opacity ()", speed); } } } / / GENERATE THE CSS FOR Preloader var myCSS; myCSS = " ; <style type= \" text/css \"> "; myCSS + = "html, body {height: auto; margin: 0px; padding: 0px;}"; myCSS + = "# preloader {"; myCSS + = "position: fixed;" myCSS + = "background-color: white;" myCSS + = "width: 100%;" myCSS + = "height: 100%;" myCSS + = "display: block;" myCSS + = "z-index: 100000;" myCSS + = "}"; myCSS + = "# preloadIMG {"; myCSS + = "position: absolute;" myCSS + = "left: 50%;" ; myCSS + = "width:" GIFpreloadLargeur + + "px;" ; myCSS + = "height:" GIFpreloadHauteur + + "px;" GIFpreloadLargeur / 2 ) + "px;" ; myCSS + = "margin-left: -" + (GIFpreloadLargeur / 2) + "px;" myCSS + = "top: 150px;" myCSS + = "}"; myCSS + = "</ style> "; / / WRITE THE CSS ( myCSS ) ; window. document. write (myCSS); / / EXECUTION ( ) { preload ( ) ; } window. onload = function () {preload ();}
Now, insert this code right after the BODY tag. Take note that the "image of the preload should be on your server and the source must be changed depending on the" edroit where is your image.
<div id="preloader"> <div id="preloadIMG"> src="loading.gif" <img alt="" /> </ div> </ Div>
Well, now you have a very smart preloader for your web pages heavy.
Tags: Images , Javascript , Preloader , XHTML






April 20th, 2008 at 12:32
except that I have a Ê that appears. If I can resolve this issue I care, if not ...
anyway thank you for this very nice script
May 20, 2008 at 11:53
great I'll test it
May 26, 2008 at 9:02
Very good initiative that preloader. This is what I need for my site, except for one thing. It prevents the loading of flash animations. Would there be a simple solution to this problem?
June 13th, 2008 at 1:24
Super code by cons, I have a concern, after the establishment of a code that works perfectly, and my menu button does it function more "rollover" in IE, while in opera, there is no problem
Thank you anyway
September 3rd, 2008 at 18:22
hello, thank you for this script is great.
but how can we modify it to load more images that are not necessarily located on the page?
September 11th, 2008 at 19:08
Great! Works very well .. but I'd also put it on the index of my web page that links to my forum, how can I integrate it with the index of my web page without putting it to all my forum pages.
I wanna just preload it from the forum index welcome .. esse possible.
January 6th, 2009 at 13:09
Frankly hats off to this piece of code really well developed. However I have a little problem.
Here is the preload starts up properly with the little animated gif only once the page loads the preload does not disappear. It remains displayed.
But where it may come? I can not find the solution ...
June 4, 2009 at 3:50
Hello,
Thank you for this script, I was looking for a long time. Congratulations it works great. Good luck.
June 10th, 2009 at 5:07
thank you for this code!
impec walk home!
October 10th, 2009 at 4:33
Hello,
I can not to load my entire site to summon please?
October 11th, 2009 at 19:52
Should see the code, do what you can give me a link development?
December 29, 2009 at 11:36
hello all
I do not understand or put fau c is the first code in the HEAD??
thank you
December 29, 2009 at 19:30
Yes you should put the code in head or in an external javascript file loader that will be in the head.
September 8, 2010 at 4:22
Too much! Thank you!
However, it does not work if there are js script that load in the header (eg Dojo with load full of stuff).
So I was forced to put these scripts in the body after the div to display the image.
Not glop, but it deserves to run.