Jump to content
xisto Community
demonlord

Loaing Script

Recommended Posts

hello, I'm looking for a preloader script for my site. like it will display an loading image while the site is loading and the once the page has loaded the image will disapear. i tryed searching for one on google but i could not find one, i think i searched for the worng thing. if some one knows how to make one or where i can find one that would be great.Thanks

Share this post


Link to post
Share on other sites

not excatly what i was looking for. i was hoping for something like browserUpdate.html has once you login in. where it shows there logo and a loading bar, and then it disaperas.

they're using flash to do it. i don't think it is possible with only javascripts.

Share this post


Link to post
Share on other sites

Hi,
I believe this is what you're looking for:

http://www.ajaxload.info/

Custom AJAX loading images.
Simply put, have an HTML element that you can address with the DOM easily, such as:

<div id="myDiv"></div>

In this div or span or whatever element you've named it, put the image in assuming you've already uploaded it of course.

<div id="myDiv"><img src="ajax-loader.gif" /></div>

Or wherever your loader image is located.
To make it disappear when the page has loaded is simple enough.
Write some AJAX and have the responseText fill in the innerHTML of the selected element.

	xmlhttp.onreadystatechange=function(){ 
if(xmlhttp.readyState==4){
document.getElementById('myDiv').innerHTML=xmlhttp.responseText;
}
};
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

</script>
linenums:0'><script type="text/javascript">function GetXmlHttpObject(){ if (window.XMLHttpRequest){ // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject){// code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); } return null;}function ajaxFunction(){ var xmlhttp=GetXmlHttpObject(); if (xmlhttp==null){ alert ("Browser does not support HTTP Request"); return; } var url="url.php"; document.getElementById('myDiv').innerHTML="Loading... <img src='images/ajax-loader2.gif'>"; //You don't need to do this if you've already put in the image. xmlhttp.onreadystatechange=function(){ if(xmlhttp.readyState==4){ document.getElementById('myDiv').innerHTML=xmlhttp.responseText; } }; xmlhttp.open("GET",url,true); xmlhttp.send(null); }</script>
Plain and simple. ;)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.