分享刚做的提示信息带延时跳转
本帖最后由 terminus 于 2013-4-24 15:49 编辑helper内容
if (!function_exists('message')) {
/*
* 信息提示跳转
* @param 标题
* @param 内容
* @param 跳转目标
* @param 跳转延时
*/
function message($title, $content, $target_url, $delay_time = 3) {
$_CI = &get_instance();
$_CI->load->view('message', array(
'title' => $title,
'content' => $content,
'target_url' => $target_url,
'delay_time' => $delay_time
));
}
}
模板内容
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title> <?php echo $title; ?> </title>
<!--
<link type="text/css" href="" rel="stylesheet" />
<script type="text/javascript" src=""></script>
-->
<style type="text/css">
body{
margin: 0;
line-height: 30px;
font-size: 12px;
}
a{
text-decoration: none;
color: #E13300;
}
ul{
list-style: none;
margin: 0;
padding: 0;
}
#container{
width: 900px;
margin: 20px auto
}
#message{
width: 500px;
margin: 200px auto;
border: 1px dotted #DDD;
}
#message .msg_title{
text-align: center;
font-weight: bold;
font-size: 14px;
padding: 5px;
border-bottom: 1px dotted #DDD;
}
#message .msg_content{
padding: 20px;
}
#message .notice{
padding: 0 10px;
text-align: right;
}
</style>
</head>
<body>
<div id="container">
<div id="message">
<ul>
<li class="msg_title"><?php echo $title; ?></li>
<li class="msg_content"><?php echo $content; ?></li>
<li class="notice"><?php echo $delay_time; ?>秒后自动跳转,<?php echo anchor($target_url, '不想等待请猛戳此处'); ?></li>
</ul>
</div>
</div>
</body>
<script type="text/javascript">
setTimeout(function() {
window.location = "<?php echo $target_url; ?>";
}, <?php echo ($delay_time * 1000); ?>);
</script>
</html>
这个怎么实现输出一个message()后就不执行后面的代码呢?我在message()后面加上exit;连message()也不会输出了。 心安即是归处 发表于 2014-7-3 10:15
这个怎么实现输出一个message()后就不执行后面的代码呢?我在message()后面加上exit;连message()也不会输出 ...
对啊,自己写一个这样的,也是不想执行下面的用exit就不能用了
打包下载
:victory::victory: 我用上了.谢谢 好东西呀 哈哈 正想要 放什么目录下呀,然后怎么引用呢? 114fh 发表于 2013-5-12 21:03 static/image/common/back.gif
放什么目录下呀,然后怎么引用呢?
helper/view
helper可全局调用 hcmtl 发表于 2013-5-14 15:43 static/image/common/back.gif
好像可以直接用..header('refresh:3; url='.site_url(''));延时跳转吧...
header需要在任何输出前使用 嗯!可以用,感谢分享!
页:
[1]
2