ThinkPHP中自定义错误页面和提示页面实例
作者:shichen2014 时间:2024-05-02 17:16:21
本文实例讲述了ThinkPHP中自定义错误页面和提示页面的方法。分享给大家供大家参考。具体实现方法如下:
在ThinkPHP中有两个方法时提示错误页面 _404('错误信息','跳转的地址');halt('提示信息');
这两个函数都可以自定义错误页面在配置文件中加
'TMPL_EXCEPTION_FILE'=>'./Public/Tpl/error.html'
这样每次就会跳转到这个页面。
下面是我定制的错误页面
在( 3 )秒后自动跳转,或直接点击 这里 跳转 停止
$this->success('错误信息','跳转的地址(最好用U())',时间);
$this->error();
下面是我改变ThinkPHP中的提示页面
<!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>提示消息 - ThinkPHP</title>
<style type="text/css">
body { font: 75% Arail; text-align: center; }
#notice { width: 300px; background: #FFF; border: 1px solid #BBB; background: #EEE; padding: 3px;
position: absolute; left: 50%; top: 50%; margin-left: -155px; margin-top: -100px; }
#notice div { background: #FFF; padding: 30px 0 20px; font-size: 1.2em; font-weight:bold }
#notice p { background: #FFF; margin: 0; padding: 0 0 20px; }
a { color: #f00} a:hover { text-decoration: none; }
</style>
</head>
<body>
<div id="notice">
<present name="message">
<p style="font: italic bold 2cm cursive,serif; color:green">
ok
</p>
<div class="success" style="width:100%;text-align:left;padding-left:10px;padding-right:10px">
<?php echo($message); ?>
</div>
<else/>
<p style="font: italic bold 2cm cursive,serif; color:red">
×
</p>
<div class="error" style="width:100%;text-align:left;padding-left:10px;padding-right:10px">
</div>
</present>
<p>
在( <span id="sec" style="color:blue;font-weight:bold"><?php echo($waitSecond); ?></span> )秒后自动跳转,或直接点击 <a href="javascript:window.location='<?php echo($jumpUrl); ?>'">这里</a> 跳转<br>
<span style="display:block;text-decoration:underline;cursor:pointer;line-height:25px" onclick="stop(this)">停止</span>
</p>
</div>
<script>
var seco=document.getElementByIdx_x("sec");
var time=<?php echo($waitSecond); ?>;
var tt=setInterval(function(){
time--;
seco.innerHTML=time;
if(time<=0){
window.location='<?php echo($jumpUrl); ?>'
return;
}
}, 1000);
function stop(obj){
clearInterval(tt);
obj.style.display="none";
}
</script>
</body>
</html>
希望本文所述对大家的ThinkPHP框架程序设计有所帮助。
标签:ThinkPHP,自定义,页面
0
投稿
猜你喜欢
python日记(使用TCP实现的对话客户端和服务器)
2023-01-25 19:42:54
JavaScript中跨域调用Flash的方法
2024-04-19 10:25:49
element-ui中表格设置正确的排序及设置默认排序
2024-05-09 15:25:48
利用Python自动生成PPT的示例详解
2021-10-16 18:25:08
Pandas中批量替换字符的六种方法总结
2022-10-23 05:23:12
JS highcharts动态柱状图原理及实现
2024-04-22 12:52:17
MySQL Explain命令用于查看执行效果
2009-02-27 15:30:00
asp error对象基础
2008-08-04 13:25:00
深入浅出SQL之左连接、右连接和全连接
2009-08-30 15:14:00
vuex mutations的两种调用方法小结
2024-04-27 16:11:42
MYSQL拒绝访问报错not allowed to connect
2024-01-16 02:20:21
详解Python文件修改的两种方式
2023-03-14 13:44:13
python设计模式之抽象工厂模式详解
2023-06-11 22:15:51
关于设计规范
2008-06-02 13:10:00
vue前端开发keepAlive使用详解
2024-05-02 16:33:52
微信小程序自定义底部弹出框动画
2024-05-02 16:14:30
django框架如何集成celery进行开发
2022-09-13 11:18:24
详解JavaScript 中的批处理和缓存
2024-04-28 09:48:03
python轻松查到删除自己的微信好友
2021-06-06 12:31:44
Python tkinter中label控件动态改变值问题
2023-09-15 19:27:18