<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" />
< title >通过URL获取html代码实现页面嵌入(代替iframe效果) </ title >
</ head >
< script type ="text/javascript" language ="javascript" >
function getHtmlContentBySoap(url,showDivId){ debugger ;
if ( ! url || url == "" ){
document.getElementById(showDivId).innerHTML = "" ;
return ;
}
if (window.XMLHttpRequest){
req = new XMLHttpRequest();
} else if (window.ActiveXObject){
req = new ActiveXObject( " Microsoft.XMLHTTP " );
}
if (req){
req.open( " GET " ,url, true );
req.onreadystatechange = function (){
getHtmlContentBySoapCallBack(url,showDivId);
};
req.send();
}
}
function getHtmlContentBySoapCallBack(url,showDivId){
if (req.readyState == 4 ){
if (req.status == 200 ){
if (document.getElementById(showDivId)){
document.getElementById(showDivId).innerHTML = req.responseText;
}
}
}
}
</ script >
< body >
< input type ="button" onclick ="getHtmlContentBySoap('http://www.baidu.com','exp_div');" style =" width:50px; height:25px;" value ="click" />
< div id ="exp_div" style ="width:980px; text-align:center;" ></ div >
</ body >
</ html >
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" />
< title >通过URL获取html代码实现页面嵌入(代替iframe效果) </ title >
</ head >
< script type ="text/javascript" language ="javascript" >
function getHtmlContentBySoap(url,showDivId){ debugger ;
if ( ! url || url == "" ){
document.getElementById(showDivId).innerHTML = "" ;
return ;
}
if (window.XMLHttpRequest){
req = new XMLHttpRequest();
} else if (window.ActiveXObject){
req = new ActiveXObject( " Microsoft.XMLHTTP " );
}
if (req){
req.open( " GET " ,url, true );
req.onreadystatechange = function (){
getHtmlContentBySoapCallBack(url,showDivId);
};
req.send();
}
}
function getHtmlContentBySoapCallBack(url,showDivId){
if (req.readyState == 4 ){
if (req.status == 200 ){
if (document.getElementById(showDivId)){
document.getElementById(showDivId).innerHTML = req.responseText;
}
}
}
}
</ script >
< body >
< input type ="button" onclick ="getHtmlContentBySoap('http://www.baidu.com','exp_div');" style =" width:50px; height:25px;" value ="click" />
< div id ="exp_div" style ="width:980px; text-align:center;" ></ div >
</ body >
</ html >