織夢dedecms系統(tǒng)ShowMsg函數(shù)妙用
時間: 2018-12-09 20:40
閱讀: 次
作者:素材無憂網(wǎng)
在對DedeCMS做2次開發(fā)的時候可能提示信息會經(jīng)常用到,為了方便在此將ShowMsg方法提取出來,使用方法:
ShowMsg(“提示信息”,“進(jìn)行跳轉(zhuǎn)的頁面URL”);
ShowMsg的代碼如下:
function ShowMsg($msg, $gourl, $onlymsg = 0, $limittime = 0) //系統(tǒng)提示信息
{
/*
*$msg 信息提示的內(nèi)容
*$gourl 需要跳轉(zhuǎn)的網(wǎng)址
*$onlymsg 1 表示不自動跳轉(zhuǎn) 0表示自動跳轉(zhuǎn)
*$limittime 跳轉(zhuǎn)的時間
*/
global $dsql, $cfg_ver_lang;
if (eregi ( "^gb", $cfg_ver_lang ))
$cfg_ver_lang = 'utf-8';
$htmlhead = "<html>\r\n<head>\r\n<title>系統(tǒng)提示</title>\r\n<meta http-equiv=\"Content-Type\"
content=\"text/html; charset=utf-8\" />\r\n";
$htmlhead .= "<base target="_self" />\r\n</head>\r\n<body leftmargin="0" topmargin="0">\r\n<center>\r\n
<script>\r\n";
$htmlfoot = "</script>
\r\n</center>\r\n</body>\r\n</html>\r\n";
if ($limittime == 0)
$litime = 3000;
else
$litime = $limittime;
if ($gourl == "-1") {
if ($limittime == 0)
$litime = 3000;
$gourl = "javascript:history.go(-1);";
}
if ($gourl == "" || $onlymsg == 1) {
$msg = "
<script>alert(\"" . str_replace ( "\"", "“", $msg ) . "\");</script>
";
} else {
$func = " var pgo=0;
function JumpUrl(){
if(pgo==0){ location='$gourl'; pgo=1; }
}\r\n";
$rmsg = $func;
$rmsg .= "document.write(\"
<div style="width:450px;padding:0px;border:1px solid #DADADA;">";
$rmsg .= "<div style='padding:6px;font-size:12px;border-bottom:1px solid #DADADA;
background:#DBEEBD url(wbg.gif)';'><b>提示信息!</b></div>\");\r\n";
$rmsg .= "document.write(\"<div style="height:130px;font-size:10pt;background:#ffffff;">
\");\r\n";
$rmsg .= "document.write(\"".str_replace("\"","“",$msg)."\");\r\n";
$rmsg .= "document.write(\"";
if ($onlymsg == 0) {
if ($gourl != "javascript:;" && $gourl != "") {
$rmsg .= "
<a href="" . $gourl . "">如果你的瀏覽器沒反應(yīng),請點(diǎn)擊這里...</a>";
}
$rmsg .= "
</div>\");\r\n";
if ($gourl != "javascript:;" && $gourl != "") {
$rmsg .= "setTimeout('JumpUrl()',$litime);";
}
} else {
$rmsg .= "
</div>\");\r\n";
}
$msg = $htmlhead . $rmsg . $htmlfoot;
}
if (isset ( $dsql ) && is_object ( $dsql ))
@$dsql->Close ();
echo $msg;
}
標(biāo)簽: