PHP automatically jumps to a page

墨辰丷
Release: 2023-03-25 18:58:02
Original
5287 people have browsed it

This article mainly introduces the method of realizing timed jump in PHP pages. An example demonstrates the technique of using header function to realize jump. Friends in need can refer to it.

history.go(-2); //javaScript code, go back two pages.
setTimeout("playSec(" num ")",1000); //JavaScript code, timer, call playSec() function after one second.

success.php Operation success page
error.php Operation failure page

1.success.php Operation success page

<?php  
$message=urldecode($_GET["message"]);  
$url=trim($_GET["url"]);  
?>  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
<title>操作成功</title>  
<style type="text/css">  
*{margin:0px;padding:0px;}  
.box{  
    width:450px;  
    border:1px solid #f0f0f0;  
    background:#FFFFCC;  
    margin:100px auto;  
    padding:20px;  
    font-size:14px;  
    line-height:180%;  
    color:#444;  
}  
h2{margin-bottom:10px;}  
#time{color:#FF0000;}  
.color2{color:#0099FF;}  
a.a1:link,a.a1:visited{color:#0099FF;text-decoration:none;}  
a.a1:hover{color:#FF0000;text-decoration:underline;}  
</style>  
</head>  
  
<body>  
<div class="box">  
    <h2 align="center">操作成功</h2>  
    <p><b>提示:<?php echo $message;?></b></p>  
    <p>系统将在 <span id="time">3</span> 秒钟后自动跳转,如果不想等待,请点击 <a class="a1" href="<?php echo $url?>">这里</a> 跳转。</p>  
</div>  
</body>  
</html>  
<script language="javascript">  
function playSec(num)  
{  
    time.innerText=num;  
    if(--num >0)  
    {  
        setTimeout("playSec("+num+")",1000);    //设置定时器,一秒后调用playSec()函数  
    }else  
    {  
        location.href="<?php echo $url?>";   //跳转到其他页面  
    }  
}  
playSec(3);  
</script>
Copy after login

2.error.php Operation failure page

<?php  
$message=urldecode($_GET["message"]);  
?>  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
<title>操作成功</title>  
<style type="text/css">  
*{margin:0px;padding:0px;}  
.box{  
    width:450px;  
    border:1px solid #f0f0f0;  
    background:#FFFFCC;  
    margin:100px auto;  
    padding:20px;  
    font-size:14px;  
    line-height:180%;  
    color:#444;  
}  
h2{margin-bottom:10px;}  
#time{color:#FF0000;}  
.color2{color:#0099FF;}  
a.a1:link,a.a1:visited{color:#0099FF;text-decoration:none;}  
a.a1:hover{color:#FF0000;text-decoration:underline;}  
</style>  
</head>  
  
<body>  
<div class="box">  
    <h2 align="center">操作失败</h2>  
    <p><b>提示:<?php echo $message;?></b></p>  
    <p>系统将在 <span id="time">5</span> 秒钟后自动跳转,如果不想等待,请点击 <a class="a1" href="javascript:history.go(-2);">这里</a> 跳转。</p>  
</div>  
</body>  
</html>  
<script language="javascript">  
function playSec(num)  
{  
    var time = document.getElementById("time");  
    time.innerText=num;  
    if(--num >0)  
    {  
        setTimeout("playSec("+num+")",1000);    //设置定时器,每一秒调用一次playSec()函数  
    }else  
    {  
        history.go(-2);   //后退两个页面  
    }  
}  
playSec(5);  
</script>
Copy after login

Related recommendations:

HTML realizes automatic page jump Five methods

PHP reports an error and automatically jumps

Automatically jumps after the PC side WeChat scans the QR code to pay successfully PHP version code sharing

3 ways to make the HTML page automatically jump after 3 seconds

The above is the detailed content of PHP automatically jumps to a page. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!