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

PHP jump does not change the browser address

王林
Release: 2023-04-07 13:54:02
Original
2900 people have browsed it

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

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

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!

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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template