一:描述
在做站的时候,经常需要一个弹出框,比如填加完毕需要弹出一个提示,修改完毕需要一个提示!这时候我们就必须用到它了!
二:作者及相关下载
作者:子弹兄
Git下载地址: http://git.oschina.net/hongweizhiyuan/phpfunction.git showMsg
三:相关代码
首先我们引用的是bootstrap.css文件来做,这也是为了国际化的一种!大家引用它都可以进行修改操作!
这一点一定要注意
/** * 通用分页函数 * @param String $msg 弹出的消息 * @param String $type 类型,-1表示点击后上一页,1表示点击进入自定义页面 * @param String $url URL * @return String $message * @author hongweizhiyuan 2014-12-20 */ function showMsg($msg,$type,$href){ $message = "<link href='http://cdn.bootcss.com/bootstrap/3.3.1/css/bootstrap.min.css' rel='stylesheet'>"; $message .= "<table class='table table-striped table-bordered' style='width:450px;margin:0 auto;margin-top:100px;' width='300' align='center'>\n\t<tr><td height=35 align='center'><strong>提示信息</strong></td></tr>\n\t"; $message .= "<tr>\n\t<td align='center' style='font-size:12px;'>".$msg."<br />"; $href = empty($href) ? $_SERVER['HTTP_REFERER'] : $href; switch ($type){ case -1: $message .= "<a href='javascript:history.go(-1)'>点击这里返回上一页</a>"; break; case 0: case 1: $message .= "<a href=\"".$href."\">如果您的浏览器没有跳转,请点击这里</a>"; $message .= "<script type='text/javascript'>setTimeout('window.location.href='".$href."',3000);</script>\n"; break; } $message .= "</td></tr></table>"; return $message; exit(); }
三:明细说明
echo showMsg("你好,世界!",-1);
这个代码执行的效果是 ,演示地址 http://www.ijquery.cn/phpfunction/showMsg/demo1.php
echo showMsg("你好,世界!",1,"http://www.baidu.com");
这个代码执行的效果,点击后进入 百度 的页面,本站演示地址 http://www.ijquery.cn/phpfunction/showMsg/demo2.php
当然 URL 可以自定义,这里自定义的 http://www.baidu.com