Home > Article > Backend Development > PHP jump does not change the browser address
There are two ways to jump to php without changing the browser address
1. Use JS to achieve
2. Use iframe implementation
The first is JS implementation, code:
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); } }
The above code is the method to keep the browser address bar address unchanged after the page jumps.
Method 2: Use iframe framework:
<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>
Disadvantages:
There is cross-domain access The problem.
Summary:
It is recommended to use the backend. The frontend is not friendly to search engines and is not conducive to optimization.
Recommended tutorial: PHP video tutorial
The above is the detailed content of PHP jump does not change the browser address. For more information, please follow other related articles on the PHP Chinese website!