织梦信息提示框美化带倒计时版

snh102 By snh102 at 2025-01-16 • 暂不可见      举报

织梦的信息提示框,非常好看但是没有显示时间。比如:稍等一下,这个稍等,都稍等一天了,都还是没有回复。所以,我要给织梦信息提示加个倒计时。

演示效果看织梦开发实现自动发布和自动更新文章》一文中的信息提示框。

如果,你用的织梦CMS。就打开:/include/common.func.php 搜索
如果,你用的织梦BIZ。就打开:/system/common.func.php 搜索

ShowMsg

看到下面这个函数

function ShowMsg($msg, $gourl, $onlymsg = 0, $limittime = 0)
{
	....中间的代码省略
}

把这整个函数改为

function ShowMsg($msg, $gourl, $onlymsg = 0, $limittime = 0)
{
    global $cfg_soft_lang, $cfg_cmsurl;
    if(empty($GLOBALS['cfg_plus_dir'])) $GLOBALS['cfg_plus_dir'] = '..';
    $htmlhead  = "<html><head><meta charset='utf-8'><title>提示信息</title><meta name='viewport' content='width=device-width,initial-scale=1'>";
    $htmlhead .= "<base target='_self'></head><body>".(isset($GLOBALS['ucsynlogin']) ? $GLOBALS['ucsynlogin'] : '')."<center><script>";
    $htmlfoot  = "</script></center></body></html>";
    $litime = ($limittime == 0 ? 1000 : $limittime);
    $func = '';
    if ($gourl == '-1') {
        if ($limittime == 0) $litime = 5000;
        $gourl = "javascript:history.go(-1);";
    }
    if ($gourl == '' || $onlymsg == 1) {
        $msg = "<script>alert(\"".str_replace("\"", "“", $msg)."\");</script>";
    } else {
        //当网址为:close::objname 时, 关闭父框架的id=objname元素
        if (preg_match('/close::/', $gourl)) {
            $tgobj = trim(preg_replace('/close::/', '', $gourl));
            $gourl = 'javascript:;';
            $func .= "window.parent.document.getElementById('{$tgobj}').style.display='none';\r\n";
        }
        $func .= "var pgo=0;function JumpUrl(){if (pgo==0){location='$gourl'; pgo=1;}}";
        $rmsg = $func;
        $rmsg .= "document.write(\"<style>body{margin:0;line-height:1.5;font:14px Helvetica Neue,Helvetica,PingFang SC,Tahoma,Arial,sans-serif;color:#424b51;background:#f2f2f2}a{color:#28a745;text-decoration:none}.xushu-tips{margin:68px auto 0;padding:0;width:420px;height:auto;background:#fff;border-radius:.2rem}.tips{margin:0 20px;padding:16px 0;border-bottom:1px solid #f6f6f6}.tips p{margin:0;padding-left:10px;line-height:16px;text-align:left;border-left:3px solid #ff5722}.frame{padding:20px;min-height:120px;color:#666}.go a{display:inline-block;margin:20px auto 0;padding:.375rem .75rem;font-size:12px;color:#fff;background:#28a745;border:1px solid #28a745;box-sizing:border-box;border-radius:.2rem;transition:all .6s;text-align:center}.go a:hover{opacity:.8}@media (max-width:768px){body{padding:0 16px}.xushu-tips{width:100%}}</style>\");";
        $rmsg .= "document.write(\"<div class='xushu-tips'>";
        $rmsg .= "<div class='tips'><p>提示信息</p></div>\");";
        $rmsg .= "document.write(\"<div class='frame'>\");";
        $rmsg .= "document.write(\"".str_replace("\"","“",$msg)."\");";
        $rmsg .= "document.write(\"";
        if($onlymsg==0)
        {
            if( $gourl != 'javascript:;' && $gourl != '')
            {
                $gogo = bcdiv($litime, '1000');$fatime = ($gogo == 0 ? 1 : $gogo);
				$rmsg .= "<div class='go'><a href='{$gourl}'>点击反应 <span id='num'>{$fatime}</span> 秒</a></div>\");";
                $rmsg .= "setTimeout('JumpUrl()',{$litime});var num={$fatime};function redirect(){num--;document.getElementById('num').innerHTML=num;if(num<0){document.getElementById('num').innerHTML=0;}}setInterval('redirect()',1000);";
            } else {
                $rmsg .= "</div>\");";
            }
        } else {
            $rmsg .= "</div>\");";
        }
        $msg  = $htmlhead.$rmsg.$htmlfoot;
    }
    echo $msg;
}

完成,加个倒计时,再也不用惆怅了。显示多久才会跳转,避免关闭又正在更新中...

温馨提示

内容由用户共同创建和维护,并不代表织梦爱好者论坛立场!
建议您独自对内容进行评估,核实并咨询相关的专业人士!

织梦信息提示框美化带倒计时版  1 个回复 | 最后更新于 2025-01-16
该部分是隐藏区

登录后查看回复

该部分是隐藏区

登录后方可回帖

Loading...