可以设置弹出信息,跳转地址,跳转的时间,跳转的信息标题提示:

手机端加上<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no'>

  1 <?php   
2 /**

3 * [_alert by qiuwei]
* @param [type] $msg [description]
* @param [type] $gourl [description]
* @param string $title [description]
* @param integer $onlymsg [description]
* @param integer $limittime [description]
* @return [type] [description]
*/
function _alert($msg, $gourl,$title='',$onlymsg=0, $limittime=0 ) { if(empty($GLOBALS['cfg_plus_dir'])) $GLOBALS['cfg_plus_dir'] = '..'; $htmlhead = "<html>\r\n<head>\r\n<title>$title</title>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\r\n"; $htmlhead .= "<base target='_self'/>\r\n<style>div{line-height:160%;}</style></head>\r\n<body>\r\n<center>\r\n<script>\r\n"; $htmlfoot = "</script>\r\n</center>\r\n</body>\r\n</html>\r\n"; //默认3秒返回 $litime = ($limittime==0 ? 3000 : $limittime); $func = ''; 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 { // 当网址为: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; } }\r\n"; $rmsg = $func; $rmsg .= "document.write(\"<br /><div style='width:300px;padding:0px;border:1px solid #DADADA;'>"; $rmsg .= "<div style='text-align: left;padding:6px;color:#000;font-size:16px;border-bottom:1px solid #DADADA;background:#F5F5F5 url({$GLOBALS['cfg_plus_dir']}/img/wbg.gif)';'><b>$title</b></div>\");\r\n"; $rmsg .= "document.write(\"<div style='height:130px;background:#fff'>\");\r\n"; $rmsg .= "document.write(\"<div style='padding:16px 5px 5px;color:000;font-size:16px;'>".str_replace("\"","“",$msg)."</div>\");\r\n"; $rmsg .= "document.write(\""; if($onlymsg==0) { if( $gourl != 'javascript:;' && $gourl != '') { // $rmsg .= "<br /><a href='{$gourl}'>如果你的浏览器没反应,请点击这里...</a>";
$rmsg .= "<div style='padding-top:10px;'><a href='{$gourl}'><button style='width:65px;height:25px;line-height:25px; background-color: #DE5923;border:0; font-size:14px;color:#fff;cursor: pointer; border-radius: 2px;text-decoration: none;'>确定</button></a></div>";
         // IE不兼容button 可直接用a链接
           //$rmsg .= "<a href='{$gourl}' style='text-decoration: none;color:#fff;'><div style='padding-top:0px;width:80px;height:30px;line-height:30px; background-color: #DE5923;border:0; font-size:14px;cursor: pointer; border-radius: 2px;'>确定</div></a>";
$rmsg .= "<br/></div>\");\r\n"; $rmsg .= "setTimeout('JumpUrl()',$litime);"; } else { $rmsg .= "<br/></div>\");\r\n"; } } else { $rmsg .= "<br/><br/></div>\");\r\n"; } $msg = $htmlhead.$rmsg.$htmlfoot; } echo $msg; } // _alert('对不起,你的信息不完整的啊!风刀霜剑韩复榘恐慌房价', ' ',$title='小鬼PSer提示:',' ','1000000');

by 小鬼PSer  2017-09-29  16:30:43

基于PHP函数的alert弹框的更多相关文章

  1. 仿写confirm和alert弹框

    在工作中,我们常常会遇到原生的样式感觉比较丑,又和我们做的项目风格不搭.于是就有了仿写原生一些组件的念头,今天我就带大家仿写一下confirm和alert样式都可以自己修改. 有些的不好的地方请指出来 ...

  2. selenium对Alert弹框的多种处理

    Alert弹框是一个很烦人的控件,因为当前页面如果弹出了该弹框,你必须要处理它,不然你就不能操作页面的其它元素,下面我列出了alert弹框在多种场景下的处理办法. 明确知道系统哪个地方会弹alert ...

  3. python工具 - alert弹框输出姓名年龄、求和

    使用python自带的tkinter库进行GUI编程,完成两个功能: (1)要求用户输入姓名和年龄然后打印出来 (2)要求用户输入一个数字,然后计算1到该数字之间的和 代码部分: # 导入tkinte ...

  4. 自定义alert弹框,title不显示域名

    问题: 系统默认的alert弹框的title会默认显示网页域名 解决办法: (修改弹框样式) (function() { window.alert = function(name) { $(" ...

  5. JavaScript实现自定义alert弹框

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAh0AAAFkCAYAAACEpYlzAAAfj0lEQVR4nO3dC5BddZ0n8F93pxOQCO

  6. 操作JavaScript的Alert弹框

    @Testpublic void testHandleAlert(){ WebElement button =driver.findElement(By.xpath("input" ...

  7. 自定义alert弹框,title不显示域名(重写alert)

    问题: 系统默认的alert弹框的title会默认显示网页域名 解决办法: (修改弹框样式) (function() { window.alert = function(name) { $(" ...

  8. 手写alert弹框(一)

    采用原生的JavaScript, html代码 <meta name="viewport" content="width=device-width, initial ...

  9. selenium常用api之切换:table切换、alert弹框切换、iframe框架切换

    10.查看浏览器打开了多少个table和当前页面在哪个table 测试:打开了浏览器后,打开了一个新的标签页之后,显示此时有2个table,浏览器中当前页面展示的是第2个页面,但是代码打印显示的仍然是 ...

随机推荐

  1. 图论trainning-part-1 E. Invitation Cards

    E. Invitation Cards Time Limit: 8000ms Memory Limit: 262144KB 64-bit integer IO format: %lld      Ja ...

  2. BNUOJ 3580 Oulipo

    Oulipo Time Limit: 1000ms Memory Limit: 65536KB   This problem will be judged on PKU. Original ID: 3 ...

  3. TOJ 4095: love168yk的选美大赛

    4095: love168yk的选美大赛  Time Limit(Common/Java):1000MS/3000MS     Memory Limit:65536KByteTotal Submit: ...

  4. tomcat的管理(manager)报错403

    管理tomcat的时候遇到了以下问题: 1.刚开始需要用户名密码,不知道用户名和密码是什么,但是输入什么都不正确. 解决办法: 自己在tomcat-users.xml中按格式添加用户 conf文件夹里 ...

  5. Understanding performance, load and stress testing

    What are performance, load and stress testing? Performance testing, load testing and stress testing ...

  6. 在 Linux 实例上自动安装并运行 VNC Server

    原文网址:https://help.aliyun.com/knowledge_detail/41181.html?spm=5176.8208715.110.11.4c184ae8mlC7Yy 您可以使 ...

  7. *LOJ#6227. 「网络流 24 题」最长k可重线段集问题

    $n \leq 500$条平面上的线段,问一种挑选方法,使得不存在直线$x=p$与挑选的直线有超过$k$个交点,且选得的直线总长度最长. 横坐标每个点开一个点,一条线段就把对应横坐标连一条容量一费用( ...

  8. BestCoder Round #29 1003 (hdu 5172) GTY's gay friends [线段树 判不同 预处理 好题]

    传送门 GTY's gay friends Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Ot ...

  9. Linux c内存泄漏检测

    在Linux下些C语言程序,最大的问题就是没有一个好的编程IDE,当然想kdevelop等工具都相当的强大,但我还是习惯使用kdevelop工具,由于没有一个习惯的编程IDE,内存检测也就成了在Lin ...

  10. django搭建开发环境

    1.安装python,安装pip,添加环境变量 2.使用虚拟环境Virtualenv,下载virtualenv解压,进入到此目录,cmd运行python setup.py install(或直接打开c ...