在对DedeCMS做2次开发的时候可能提示信息会经常用到,为了方便在此将ShowMsg方法提取出来,使用方法:
ShowMsg(“提示信息”,“进行跳转的页面URL”);
ShowMsg的代码如下:
function ShowMsg($msg, $gourl, $onlymsg = 0, $limittime = 0) //系统提示信息
{
/*
*$msg 信息提示的内容
*$gourl 需要跳转的网址
*$onlymsg 1 表示不自动跳转 0表示自动跳转
*$limittime 跳转的时间
*/
global $dsql, $cfg_ver_lang;
if (eregi ( "^gb", $cfg_ver_lang ))
$cfg_ver_lang = 'utf-8';
$htmlhead = "<html>rn<head>rn<title>系统提示</title>rn<meta http-equiv="Content-Type"
content="text/html; charset=utf-8" />rn";
$htmlhead .= "<base target='_self'/>rn</head>rn<body leftmargin='0' topmargin='0'>rn<center>rn<script>rn";
$htmlfoot = "</script>rn</center>rn</body>rn</html>rn";
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; }
}rn";
$rmsg = $func;
$rmsg .= "document.write("<br /><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>");rn";
$rmsg .= "document.write("<div style='height:130px;font-size:10pt;background:#ffffff'><br />");rn";
$rmsg .= "document.write("".str_replace(""","“",$msg)."");rn";
$rmsg .= "document.write("";
if ($onlymsg == 0) {
if ($gourl != "javascript:;" && $gourl != "") {
$rmsg .= "<br/><br/><a href='" . $gourl . "'>如果你的浏览器没反应,请点击这里…</a>";
}
$rmsg .= "<br/><br/></div>");rn";
if ($gourl != "javascript:;" && $gourl != "") {
$rmsg .= "setTimeout('JumpUrl()',$litime);";
}
} else {
$rmsg .= "<br/><br/></div>");rn";
}
$msg = $htmlhead . $rmsg . $htmlfoot;
}
if (isset ( $dsql ) && is_object ( $dsql ))
@$dsql->Close ();
echo $msg;
}
暂无评论内容