
php跳转页面后,浏览器地址栏地址保持不变。
有两个方法,一个使用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);
}
}上面的代码就是实现页面跳转后,浏览器地址栏地址保持不变的方法。
立即学习“PHP免费学习笔记(深入)”;
二、iframe框架
<iframe id="frame3d" name="frame3d" frameborder="0" width="100%" scrolling="auto" style="margin-top: -4px;" onload="this.style.height=document.body.clientHeight-84" height="100%" src="http://www.5202m.com" mce_src="http://www.baidu.com"> </iframe>
注意:存在跨域访问的问题,推荐后台使用,前台对搜索引擎不友好,不利于优化。
推荐教程:PHP视频教程
以上就是php跳转页面url不变的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号