有两个方法,一个使用JS实现,一个是用iframe实现。

首先是JS实现,废话就不多说了,上代码

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=utf-8");
    XMLHttpR.onreadystatechange = processResponse;
    XMLHttpR.send(null);
}
function processResponse(){
    if(XMLHttpR.readyState ==4 && XMLHttpR.status == 200){
        document.write(XMLHttpR.responseText);
    }
}

上面的代码就是实现页面跳转后,浏览器地址栏地址保持不变的方法。

方法二:

使用iframe框架:

<iframe >

</iframe>

缺点是,存在跨域访问的问题。

推荐后台使用,前台对搜索引擎不友好,不利于优化

 

 

 

转载至http://blog.sina.com.cn/s/blog_74f702e601013t0i.html

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-09
  • 2021-12-21
  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
  • 2022-03-09
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-21
  • 2021-10-08
  • 2021-08-05
  • 2022-12-23
相关资源
相似解决方案