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

手机端加上<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. MapReduce和Hadoop流

    MapReduce:分布式计算的框架 MapReduce是一个软件框架,可以将单个计算作业分配给多台计算机执行. MapReduce在大量节点组成的集群上运行.它的工作流程是:单个作业被分成很多小份, ...

  2. bzoj 4401 块的计数 思想+模拟+贪心

    块的计数 Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 455  Solved: 261[Submit][Status][Discuss] Descr ...

  3. bzoj 5055: 膜法师 树状数组+离散

    先枚举每一个数,看它前面有几个比它小,算一下和为sum1,后面有几个比它大,算一下和为sum2,对答案的贡献为A[i]*sum1*sum2. 离散化后,树状数组就可以了. 就是倒着一边,顺着一边,统计 ...

  4. HDU 2197 本源串

    如果一个串能完全由其子串组成,那么这个串就不是本源串 求长度为n的本源串的个数. 由定义一个串如果不是本源串,那么他的长度一定是组成其子本源串的长度的(>=1) 整数倍. 那么长度为n的串总个数 ...

  5. android开发里遇到的坑——eclipse项目导入android studio以后Run按钮灰色

    android studio编译有错误但是没有提示给用户,关闭android studio重新启动项目后,会显示错误,修复以后即可!

  6. 在GridView中的每一页末尾添加空行

    原文发布时间为:2008-08-03 -- 来源于本人的百度文章 [由搬家工具导入] protected void GridView1_RowCreated(object sender, GridVi ...

  7. Codeforces Round #278 (Div. 2) B. Candy Boxes [brute force+constructive algorithms]

    哎,最近弱爆了,,,不过这题还是不错滴~~ 要考虑完整各种情况 8795058                 2014-11-22 06:52:58     njczy2010     B - Ca ...

  8. linux的内存性能评估

    linux的内存性能评估 参考自:自学it网,http://www.zixue.it/. (1)使用free指令监控内存,参数-m以M为单位显示,-h人性化显示单位. [test@localhost ...

  9. django cookie session操作

    Cookie是什么? cookie说的直白点就是保存在用户浏览器端的一个键值对,举个例子,你现在登录了京东商城,你把浏览器关闭之后,你再打开京东,你还是可以对你的账户继续操作,已经购买的商品,订单都是 ...

  10. Codeforces Round #320 (Div. 2) [Bayan Thanks-Round]

    一部分题解,算是自己SB了 上午的TC 也是这样 写好了代码,却一直没注意细节,然后以为错了. 此处省100字,ps 貌似紫了,作为一个老菜鸡,终于紫了 A,B 都是语文题 C: 给以一个三角形一样的 ...