Go to my github

javascript:页面后载入

主程序

代码
 function getXmlhttp()
    {
        
var http_request;
        
        
if(window.XMLHttpRequest) { 
            http_request 
= new XMLHttpRequest();
            
if (http_request.overrideMimeType) {
                http_request.overrideMimeType(
"text/xml");
            }
        }
        
else if (window.ActiveXObject) { 
            
try {
                http_request 
= new ActiveXObject("Msxml2.XMLHTTP");
            } 
catch (e) {
                
try {
                    http_request 
= new ActiveXObject("Microsoft.XMLHTTP");
                } 
catch (e) {}
            }
        }
        
if (!http_request) { 
            window.alert(
"can't create XMLHttpRequest object.");
            
return null;
        }
        
return http_request;
    }
  
function loadAJAXTab(url,contentid){
   
try {
        
var ocontent=document.getElementById(contentid);
            
        
var xhttp=getXmlhttp();        
            xhttp.onreadystatechange
=function(){
                
if(xhttp.readyState == 4 && (xhttp.status==200 || window.location.href.indexOf("http")==-1))
                {            
                    
var resText=xhttp.responseText;
                    
                    
if (resText!="")
                    {
                     ocontent.innerHTML
=resText;
                   }
                }
                
            }
        xhttp.open(
"GET",url,true);
        xhttp.send(
null);
         } 
catch (e) {}
    }
 
loadAJAXTab("数据","页面ID");
function LoadHtmlBody(){
    loadAJAXTab("http://home.lfang.com/IndexBusi.aspx?reqBusi=User_head","topHeadTool");
 }

 

 <body onload="LoadHtmlBody();">

   <div id="topHeadTool">  </div>

</body>

posted @ 2010-03-04 14:57 罗敏贵 阅读(...) 评论(...) 编辑 收藏