| 1234567891011121314151617181920212223242526272829303132333435363738 |
- var xmlHttp;
- var url="http://www.qq.com";
- function createXMLHttpRequest() { //����һ��xmlHttpRequest����
- if (window.ActiveXObject) {
- xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
- }
- else if (window.XMLHttpRequest) {
- xmlHttp = new XMLHttpRequest();
- }
- }
- function loading(){
- createXMLHttpRequest();
- xmlHttp.onreadystatechange = handleStateChange; //����״̬�ı��¼�����handleStateChange����
- xmlHttp.open("GET",url); //����get�����ύ���
- xmlHttp.send(null);
- }
- function handleStateChange(){
- var loadcontent = document.createElement("div");
- loadcontent.style.width=document.body.clientWidth;
- loadcontent.style.height=document.documentElement.clientHeight;
- loadcontent.className="loading";
- document.body.appendChild(loadcontent);
- if(xmlHttp.readystate == 4){ //��ʾ����״̬ 4Ϊ���
- if(xmlHttp.status == 200){ //http״ָ̬ʾ�룬200��ʾok
- loadcontent.style.display="none";
- }
- }
- else loadcontent.style.display="block";//����Ӧδ��ɵĻ�������ʾloading..
- }
- if (document.all){
- window.attachEvent('onload',loading)//IE��,document.all�����������ж��Ƿ���ie�Ĺ���
- }
- else{
- window.addEventListener('load',loading,false);//firefox
- }
|