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

手机端加上<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. IIS PUT

    测试版本:IIS6.0 利用工具 1.IIS PUT Scaner By ZwelL 2.桂林老兵IIS写权限利用程序   -------------------------------------- ...

  2. JSP标签:jsp内置标签、jstl标签、自定义标签

     一.jsp标签的分类: 1)内置标签(动作标签): 不需要在jsp页面导入标签 2)jstl标签: 需要在jsp页面中导入标签 3)自定义标签 : 开发者自行定义,需要在jsp页面导入标签    1 ...

  3. iOS知识列表

    Xib和StoryBoard,自动布局地图导航,实时公交,第三方地图应用本地推送通知,网络推送通知,真机调试,应用上传绘图,图表,曲线图 Xcode使用技巧多线程,runtime机制编码解码,加密设备 ...

  4. 【容器人必看】你一定要来 ECUG Con 2018 的三个理由!

    引领国内云领域风向的高端峰会 ECUG Con 2018,即将在 12 月 22-23 日 深圳南山 全新启程!如果你的工作和容器内容相关联,如果你的兴趣和容器技术有交集,如果你是「容器人」,那么这就 ...

  5. BZOJ 3990 [SDOI2015]排序 ——搜索

    [题目分析] 可以发现,操作的先后顺序是不影响结果的,那么答案就是n!的和. 可以从小的步骤开始搜索,使得每一个当前最小的块都是上升的数列,然后看看是否可行即可. 复杂度好像是4^n [代码](哪里写 ...

  6. KVM 存储虚拟化

    KVM 的存储虚拟化是通过存储池(Storage Pool)和卷(Volume)来管理的. Storage Pool 是宿主机上可以看到的一片存储空间,可以是多种类型,后面会详细讨论.Volume 是 ...

  7. UVa10491 Cows and Cars

    #include<iostream> #include<cstdio> #include<algorithm> int main(){ double a,b,c; ...

  8. Peaks BZOJ 3545 / Peaks加强版 BZOJ 3551

    Peaks [问题描述] 在Bytemountains有N座山峰,每座山峰有他的高度h_i.有些山峰之间有双向道路相连,共M条路径,每条路径有一个困难值,这个值越大表示越难走,现在有Q组询问,每组询问 ...

  9. ZOJ - 3816 Generalized Palindromic Number dfs

    Generalized Palindromic Number Time Limit: 2 Seconds                                     Memory Limi ...

  10. 使用selenium抓取淘宝的商品信息

    淘宝的页面大量使用了js加载数据,所以采用selenium来进行爬取更为简单,selenum作为一个测试工具,主要配合无窗口浏览器phantomjs来使用. import re from seleni ...