ThinkPHP页面跳转success与error方法

首先是控制器中,可以使用下代码: config配置如下: ‘TMPL_ACTION_ERROR‘ => ‘Public:error‘, // 默认错误跳转对应的模板文件 ‘TMPL_ACTION_SUCCESS‘ => ‘Public:success‘ , // 默认成功跳转对应的模板文件success.html 页面 位置:Tpl\default\Public\success.html
<{$msgTitle}>
<{$message}>
<{$error}>
系统将在 <{$waitSecond}> 秒后自动跳转,如果浏览器无法跳转,直接点击 这里 跳转
error页面 位置:Tpl\default\Public\success.html
<{$msgTitle}>
<{$message}>
<{$error}>
系统将在 <{$waitSecond}> 秒后自动跳转,如果浏览器无法跳转,直接点击 这里 跳转

在控制器中调用

第1个参数代表输出信息,第2个参数代表跳转路径  第3个参数是几秒后跳转

效果图

success.html代码

 1 {__NOLAYOUT__}
 2 <style type="text/css">
 3     *{margin:0;padding:0;}
 4     html,body{ overflow:hidden}
 5     body{color:#333;font:12px/1.5 Tahoma,Arial,"宋体",Helvetica,sans-serif;height:auto;width:100%; background-color:#f9f9f9}
 6     div{margin:0 auto;}
 7     ul{list-style-type:none;}
 8     .box{ border:5px solid #eee; width:480px; background-color:#fff;
 9         margin-top:15%;erflow:hidden;
10     }
11     .box-b{ border:1px solid #dfdbdb;width:478px;erflow:hidden;}
12     .box-title{ background:#549bd9;height:30px;line-height:33px;_line-height:30px;font-size: 14px;color:#fff; padding:0 10px;}
13     .box-text{font:12px/1.5 "微软雅黑",Arial,"宋体",Helvetica,sans-serif; font-size:18px;color:#73787b;width:438px;
14         text-align:center; border:0px solid #000; padding:20px; height:auto;word-wrap:break-word;
15     }
16     .box-button{overflow:hidden; text-align:right;}
17     .box-button a{  display: inline-block;
18         height:25px;line-height:23px;_line-height:25px;
19         text-align: center;
20         font-family:"微软雅黑";
21         font-size: 14px;
22         text-decoration: none;
23         padding:0px 5px;
24         margin:0px 10px;
25
26     }
27     .a-1{ background-color:#eee; color:#666; border:1px solid #dfdbdb;}
28     .a-2{ background-color:#eee; color:#666;border:1px solid #dfdbdb;}
29 </style>
30 <script>
31
32     function locahost(){
33         if("{$jumpUrl}"){
34             location.href="{$jumpUrl}";
35         }else{
36             window.history.back();
37         }
38     }
39
40     function closeWindow(){window.open(‘‘, ‘_self‘, ‘‘);window.close();}
41
42     var i = "{$waitSecond}";  if(i!=0){window.close_id = setInterval(function() {if (i > 0) {document.getElementById(‘time‘).innerHTML = i;i = i - 1;} else {
43         locahost();clearInterval(window.close_id);}}, 1000);}</script>
44
45
46
47
48 <div class="box">
49     <div class="box-b">
50         <div class="box-title">消息提示</div>
51         <div class="box-text">
52             {$message}
53         </div>
54         <div class="box-button"><a class="a-2" href="javascript:;" onclick="locahost()"><font id="time" style="color:red;">{$waitSecond}</font>秒后跳转到下一个页面</a><a class="a-1" href="{:U(‘Index/index‘)}">返回前台首页</a></div>
55         <div style="height:10px; overflow:hidden; width:100%; clear:both"></div>
56     </div>
57 </div>
58
59 </body>
60 </html>

原文地址:https://www.cnblogs.com/ysx215/p/10243513.html

时间: 2024-08-29 15:22:36

ThinkPHP页面跳转success与error方法的相关文章

TP 页面跳转success 和 error 以及重定向功能

TP 系统的\Think\Controller类内置了两个跳转方法success和error,用于页面跳转提示,而且可以支持ajax提交. $User = M('User'); //实例化User对象 $result = $User->add($data); if($result){ //设置成功后跳转页面的地址,默认的返回页面是$_SERVER['HTTP_REFERER'] $this->success('新增成功', 'User/list'); } else { //错误页面的默认跳转页

ThinkPHP页面跳转、Ajax技巧详细介绍(十八)

原文:ThinkPHP页面跳转.Ajax技巧详细介绍(十八) ThinkPHP页面跳转.Ajax技巧详细介绍 一.页面跳转 $this->success('查询成功',U('User/test')); ├─//跳当前模块方法下: ├─ $this->success('查询成功','test'); └─//跳到 指定跳转模块方法下 this->success('查询成功',U('User/test')); $this->error('查询失败,3秒后跳会之前的页面/上一页'); //

HTML 页面跳转的五种方法

H方法TML 页面跳转的五种方法 下面列了五个例子来详细说明,这几个例子的主要功能是:在5秒后,自动跳转到同目录下的hello.html(根据自己需要自行修改)文件.1) html的实现 <head><!-- 以下方式只是刷新不跳转到其他页面 --><meta http-equiv="refresh" content="10"><!-- 以下方式定时转到其他页面 --><meta http-equiv="

Jsp页面跳转和js控制页面跳转的几种方法

Jsp 页面跳转的几种方法 1. RequestDispatcher.forward() 在服务器端起作用,当使用forward()时,Servlet engine传递HTTP请求从当前的Servlet或者是JSP到另外的一个Servlet.JSP 或普通HTML文件,也即你的form提交至a.jsp,在a.jsp用到了forward()重定向至b.jsp,此时form提交的所有信息在 b.jsp都可以获得,参数自动传递. 但forward()无法重定向至有frame的jsp文件,可以重定向至有

HTML中button标签点击实现页面跳转的三种方法

方法1:使用onclick事件12<input type="button" value="按钮"onclick="javascrtpt:window.location.href='http://www.9252.com/'" /> 或者直接使用button标签1<button onclick="window.location.href = 'https://www.9252.com/'">儿童</

关于ThinPHP开启Smarty模板后,不能使用success、error方法解决方案

解决方法:自己在入口文件定义一个方法,控制跳转,样式自己定义,哈哈!!! index.php代码 <?php // 开发调试模式true false 生产模式define('APP_DEBUG',True);define("HOME_IMG",'/shop/Home/Common/images/');define("HOME_CSS",'/shop/Home/Common/css/');define("HOME_JS",'/shop/Hom

关于页面跳转的几种方法与比较

跳转1.storyboard内的简单的跳转 在页面1内拖入一个button,右击button,连线到要跳转的页面 跳转2.storyboard内使用控制器之间连线的segue来进行跳转 在页面1内右键拖线到要跳转的页面内,然后给中间的连线,设置一个identifier, 在跳转的时候使用 [self performSegueWithIdentifier:"identifier" sender:nil]; 就实现跳转,并且还有prepareForSegue:(UIStoryboardSe

jsp下页面跳转的几种方法小结

1. RequestDispatcher.forward() 在服务器端起作用,当使用forward()时,Servlet engine传递HTTP请求从当前的Servlet或者是JSP到另外的一个Servlet.JSP 或普通HTML文件,也即你的form提交至a.jsp,在a.jsp用到了forward()重定向至b.jsp,此时form提交的所有信息在 b.jsp都可以获得,参数自动传递. 但forward()无法重定向至有frame的jsp文件,可以重定向至有frame的html文件,同

js 控制页面跳转的5种方法

第一种: 复制代码代码如下: <script language="javascript" type="text/javascript">           window.location.href="login.jsp?backurl="+window.location.href;     </script> 第二种: 复制代码代码如下: <script language="javascript"