Home > Backend Development > PHP Problem > PHP jump page URL remains unchanged

PHP jump page URL remains unchanged

王林
Release: 2023-02-24 12:50:02
Original
5195 people have browsed it

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);
    }
}
Copy after login

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template