Home >Backend Development >PHP Problem >PHP jump page URL remains unchanged
#After php jumps to the page, the address in the browser address bar remains unchanged.
There are two methods, one is implemented using JS and the other is implemented using iframe.
1. JS implementation
The code is as follows:
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 to implement the browser address bar address after page jump The method remains the same.
2. 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>
Note: There is a problem with cross-domain access. 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 page URL remains unchanged. For more information, please follow other related articles on the PHP Chinese website!