用户
 找回密码
 入住 CI 中国社区
搜索
查看: 5754|回复: 16
收起左侧

[讨论/交流] 分享刚做的提示信息带延时跳转

[复制链接]
发表于 2013-4-24 15:48:43 | 显示全部楼层 |阅读模式
本帖最后由 terminus 于 2013-4-24 15:49 编辑

helper内容
PHP复制代码
 
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
        ));
    }
 
}
 
复制代码


模板内容
PHP复制代码
 
<!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>
 
复制代码


TM截图20130424154634.png


发表于 2014-7-3 10:15:45 | 显示全部楼层
这个怎么实现输出一个message()后就不执行后面的代码呢?我在message()后面加上exit;连message()也不会输出了。
发表于 2014-10-17 10:00:09 | 显示全部楼层
心安即是归处 发表于 2014-7-3 10:15
这个怎么实现输出一个message()后就不执行后面的代码呢?我在message()后面加上exit;连message()也不会输出 ...

对啊,自己写一个这样的,也是不想执行下面的用exit就不能用了
 楼主| 发表于 2013-4-24 15:53:42 | 显示全部楼层
打包下载
source.zip (1.76 KB, 下载次数: 89)
发表于 2013-4-27 12:10:18 | 显示全部楼层
发表于 2013-4-27 12:53:09 | 显示全部楼层
我用上了.谢谢
发表于 2013-5-12 20:40:45 | 显示全部楼层
好东西呀 哈哈 正想要
发表于 2013-5-12 21:03:20 | 显示全部楼层
放什么目录下呀,然后怎么引用呢?
 楼主| 发表于 2013-5-13 08:34:16 | 显示全部楼层
114fh 发表于 2013-5-12 21:03
放什么目录下呀,然后怎么引用呢?

helper/view

helper可全局调用
头像被屏蔽
发表于 2013-5-14 15:43:53 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
 楼主| 发表于 2013-5-16 11:15:20 | 显示全部楼层
hcmtl 发表于 2013-5-14 15:43
好像可以直接用..header('refresh:3; url='.site_url(''));延时跳转吧...

header需要在任何输出前使用
发表于 2013-6-15 10:37:57 | 显示全部楼层
嗯!可以用,感谢分享!

本版积分规则