Return to Snippet

Revision: 42547
at March 7, 2011 01:10 by pavanrulz


Initial Code
<html>
<title>Simple Page Loader</title>
<head>
<script>

var setCnt=3;//number of extra characters
var currentCnt=0;//
var ctxt;
var settimer;
var extraTxt='.';
var originalTxt='Loading';
function loadtext(txt){
if(currentCnt<setCnt){


document.getElementById('msg').innerHTML=txt+extraTxt;
ctxt=document.getElementById('msg').innerHTML;
currentCnt++;
settimer= setTimeout("loadtext(ctxt)",200);
}
else{
document.getElementById('msg').innerHTML=originalTxt;
ctxt=document.getElementById('msg').innerHTML;
currentCnt=0;
settimer= setTimeout("loadtext(ctxt)",200);
}
}

</script>
</head>
<body>
<span id='msg'>
	
	Loading.

</span>



<script>
//call function
loadtext(originalTxt);
//in live environment uncomment below code  and comment setTimeout code
//window.onload=document.getElementById('msg').style.display='none';

//to test on fast loading page use a below delay and uncomment below code  and comment above code
setTimeout("document.getElementById('msg').style.display='none'",5000);

window.unload="document.getElementById('msg').style.display='block';loadtext(originalTxt)";
//prevent unwanted processing of javascript after 6 sec
setTimeout("clearTimeout(settimer);",6000);



</script>

</body>
</html>

Initial URL

                                

Initial Description
Using image to display page loading message count an extra dns request.
making moving text message with javascript increases performance of page loader

Initial Title
Moving Page Loader Text Message

Initial Tags
page

Initial Language
JavaScript