织梦CMS ShowMsg函数妙用

分类:标签语法教程 发布时间:2019-05-23 22:12:28

摘要:织梦CMS ShowMsg函数如何&怎么妙用?dede ShowMsg函数妙用教程&方法,适用于织梦5.7

为了方便在此将ShowMsg方法提取出来,使用方法:

ShowMsg(“提示信息”,“进行跳转的页面URL”);

ShowMsg的代码如下:

  1. function ShowMsg($msg, $gourl, $onlymsg = 0, $limittime = 0) //系统提示信息
  2. {
  3. /*
  4. *$msg 信息提示的内容
  5. *$gourl 需要跳转的网址
  6. *$onlymsg 1 表示不自动跳转 0表示自动跳转
  7. *$limittime 跳转的时间
  8. */
  9. global $dsql, $cfg_ver_lang;
  10. if (eregi ( "^gb", $cfg_ver_lang ))
  11. $cfg_ver_lang = 'utf-8';
  12. $htmlhead = "<html>\r\n<head>\r\n<title>系统提示</title>\r\n<meta http-equiv=\"Content-Type\"
  13. content=\"text/html; charset=utf-8\" />\r\n";
  14. $htmlhead .= "<base target='_self'/>\r\n</head>\r\n<body leftmargin='0' topmargin='0'>\r\n<center>\r\n<script>\r\n";
  15. $htmlfoot = "</script>\r\n</center>\r\n</body>\r\n</html>\r\n";
  16. if ($limittime == 0)
  17. $litime = 3000;
  18. else
  19. $litime = $limittime;
  20. if ($gourl == "-1") {
  21. if ($limittime == 0)
  22. $litime = 3000;
  23. $gourl = "javascript:history.go(-1);";
  24. }
  25. if ($gourl == "" || $onlymsg == 1) {
  26. $msg = "<script>alert(\"" . str_replace ( "\"", "“", $msg ) . "\");</script>";
  27. } else {
  28. $func = "     var pgo=0;
  29. function JumpUrl(){
  30. if(pgo==0){ location='$gourl'; pgo=1; }
  31. }\r\n";
  32. $rmsg = $func;
  33. $rmsg .= "document.write(\"<br /><div style='width:450px;padding:0px;border:1px solid #DADADA;'>";
  34. $rmsg .= "<div style='padding:6px;font-size:12px;border-bottom:1px solid #DADADA;
  35. background:#DBEEBD url(wbg.gif)';'><b>提示信息!</b></div>\");\r\n";
  36. $rmsg .= "document.write(\"<div style='height:130px;font-size:10pt;background:#ffffff'><br />\");\r\n";
  37. $rmsg .= "document.write(\"".str_replace("\"","“",$msg)."\");\r\n";
  38. $rmsg .= "document.write(\"";
  39. if ($onlymsg == 0) {
  40. if ($gourl != "javascript:;" && $gourl != "") {
  41. $rmsg .= "<br/><br/><a href='" . $gourl . "'>如果你的浏览器没反应,请点击这里...</a>";
  42. }
  43. $rmsg .= "<br/><br/></div>\");\r\n";
  44. if ($gourl != "javascript:;" && $gourl != "") {
  45. $rmsg .= "setTimeout('JumpUrl()',$litime);";
  46. }
  47. } else {
  48. $rmsg .= "<br/><br/></div>\");\r\n";
  49. }
  50. $msg = $htmlhead . $rmsg . $htmlfoot;
  51. }
  52. if (isset ( $dsql ) && is_object ( $dsql ))
  53. @$dsql->Close ();
  54. echo $msg;