实现页面的跳转后,浏览器的地址栏不变
(2012-07-11 09:49:47)
标签:
iframe跳转js页面跳转跳转地址栏不变杂谈 |
分类: 专业小文 |
方法一:
使用js脚本:
<script language=javascript>
function createXMLHttpRequest(){
if(window.XMLHttpRequest){
XMLHttpR = new XMLHttpRequest();
}else if(window.ActiveXObject){
try{
XMLHttpR = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
XMLHttpR = new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){
}
}
}
}
function sendRequest(url){
createXMLHttpRequest();
XMLHttpR.open("GET",url,true);
XMLHttpR.setRequestHeader("Content-Type","text/html;charset=gb2312");
XMLHttpR.onreadystatechange = processResponse;
XMLHttpR.send(null);
}
function processResponse(){
if(XMLHttpR.readyState ==4 &&
XMLHttpR.status == 200){
document.write(XMLHttpR.responseText);
}
}
sendRequest("http://www.Baidu.com/");
</script>
方法二:
使用iframe框架:
<iframe id="frame3d" name="frame3d"
frameborder="0" width="100%" scrolling="auto"
</iframe>
缺点是,存在跨域访问的问题。

加载中…