Thursday, March 10, 2011

Javascript Preloader

Well this javascript function is called on body onload
that basically hide the div having loading image when the when the body loads before that it keep showing the image

you javscript function for this :


  <script type="text/javascript">



        function is_loaded()
        {
            if (document.getElementById)
                {//DOM
                 document.getElementById('preloader').style.visibility='hidden';
                }
            else
                {
                    if (document.layers)
                 { //NS4
                   document.preloader.visibility = 'hidden';
                }
                 else
                    { //IE4
                        document.all.preloader.style.visibility = 'hidden';
                     }
                 }
        }


After this replace your body tag with this


<body onload="is_loaded();">



and in you html insert this div ::


<div id="preloader"  style="position:absolute; left:-5%; top:70px; width:350px; height:120px; text-align:center"> <center> <div><img src="images/loading-gif.gif" /></div> </center> </div>

replace the src of image accordingly or you can have simple plain text also!!!

No comments:

Post a Comment