如何实现信息提示页面
用CI 做后台时,保存成功, 跳转时希望出现一个3秒钟的 ,保存成功或者失败的提示页面,如何实现啊? 本帖最后由 sdink 于 2012-1-15 13:43 编辑
http://codeigniter.org.cn/forums/data/attachment/album/201201/15/134321ky9vzz8hs4fyr78s.jpghttp://codeigniter.org.cn/forums/data/attachment/album/201201/15/134321ky9vzz8hs4fyr78s.jpg
tip-top.png
和
btn.png
请自从phpwind下找,这个是基于phpwindwidget ,感谢phpwind
函数
function Messager($message, $redirectto = '', $time = 1, $return_msg = false, $js = null) {
$msg = "$message";
$msg .= "<script>setTimeout(\"window.location.href ='$redirectto';\", " . ($time * 1000) . ");</script>";
//$skname = 'messager';
include_once APPPATH . 'views/messager.php';
exit ();
}
views
<!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">
body { font-size:12px; padding:0; margin:0; }
a { text-decoration:none; color:#1b72af; }
a:hover { text-decoration:underline; }
ol { list-style-type:decimal; margin-left:24px; color:#888; }
.fl { float:left; }
.fr { float:right; }
.tar { text-align:right; }
.mt10 { margin-top:10px; }
.mr20 { margin-right:20px; }
.mb20 { margin-bottom:20px; }
.lh2 { line-height:2; }
.vt { vertical-align:top; }
.tip-page { width:600px; margin:100px auto 30px; }
.tip-table { margin:0 1px; background:#ffffff; width:598px; }
.tip-top { background:url(http://192.168.1.103:8099/shop/skin/images/ico/tip-top.png) center no-repeat; height:50px; }
.tip-bgA, .tip-bgB, .tip-bgC, .tip-bgC { background:#1b72af; }
.tip-bgA, .tip-bgB { height:1px; overflow:hidden; }
.tip-bgA { margin:0 2px; }
.tip-bgB { margin:0 1px; }
.tip-bgC { padding-top:1px; }
.tip-content { padding:0 0 0 67px; }
.tip-content tr td { padding:5px 10px 5px 0; line-height:25px; }
.show-back { text-decoration:underline; display:block; padding-right:25px; line-height:22px; overflow:hidden; background:url(http://192.168.1.103:8099/shop/images/tips-back.gif) right 0 no-repeat; height:20px; float:left; }
.show-back:hover { background-position:right -20px; }
.btn { border-color:#1b72af; margin-right:1em; color:#fff; background:#1b72af; }
.btn, .bt { border-width:1px; cursor:pointer; padding:.1em 1em; *padding:0 1em;
font-size:9pt; line-height:130%; overflow:visible; }
.bt { cursor:pointer; background:#f7f7f7 url(http://192.168.1.103:8099/shop/images/btn.png) 0 -52px repeat-x; vertical-align:middle; border-color: #e4e4e4 #cccccc #cccccc #e4e4e4; }
/*form*/
input { font:12px Arial; padding:1px 3px 0 3px; vertical-align:middle; margin-bottom:1px; }
.input { border: 1px solid; border-color: #c0c0c0 #ededed #ededed #c0c0c0; padding:2px 0px 2px 1px; font-size:1.0em; vertical-align:middle; color:#000; }
</style>
</head>
<body>
<script>
function redirect(url) {
window.location.replace(url);
}
</script>
<div class="tip-page">
<div class="tip-bgA"></div>
<div class="tip-bgB"></div>
<div class="tip-bgC">
<div class="tip-top"></div>
<table cellpadding="0" cellspacing="0" class="tip-table">
<tr>
<td height="170"><div class="tip-content">
<li><span class="opreate_span"><?=$message?></span></li>
<li class="li_nostyle"><span id="stime" style="color:#cc0000"></span> <a href="<?=$redirectto?>">秒后自动跳转到相关页面</a> </li>
</div>
<div class="tar cc mb20"> <a href="javascript:;" class="mr20" tabindex="20">返回继续操作</a><a href="http://192.168.1.103:8099/shop/" class="mr20" tabindex="20" id="showindex">返回首页</a> </div></td>
</tr>
</table>
</div>
<div class="tip-bgB"></div>
</div>
<script language="javascript">
var i='<?=$time?>';
function myclock(){
document.getElementById("stime").innerHTML = i;
if(i>0){
setTimeout("myclock();",1000);
}else{
window.location='<?=$redirectto?>';
}
i--;
}
myclock();
</script>
</body>
</html>
controllers
Messager ( '数据不存在', site_url () );
更多参数自己想象吧
不像要那么复杂的呀, zionwang 发表于 2012-1-15 14:07 static/image/common/back.gif
不像要那么复杂的呀,
很多种方法啊。
比如,你自己写个my_controller继续ci_controller.然后你的其他控制器继续my_controller,然后my_controller上写个show_message方法。
或者你写一个helper.专用用来show_message就好了。
方法就用$this->view('show_message',array());这样就行了。
把要显示的信息传过去,然后模板你还可以随便改。 在你的views文件中,html的head区域加上下面这段代码:
<meta http-equiv="refresh" content="3;url=你要跳转的url,你可以使用PHP指定一个变量在这里">
使用mete的refresh即可,
可以在详细一点会更好一点,看有一点点懂 你写个覆盖的DIV不就行了 每个控制器都要写信息提示,那会很烦琐的
页:
[1]