Home  >  Article  >  Backend Development  >  PHP jump does not change the browser address

PHP jump does not change the browser address

王林
王林Original
2019-09-29 17:48:022817browse

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!

Statement:
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
Previous article:php cannot get real ipNext article:php cannot get real ip