zoukankan      html  css  js  c++  java
  • 基于PHP函数的alert弹框

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

    手机端加上<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] 4 * @param [type] $msg [description] 5 * @param [type] $gourl [description] 6 * @param string $title [description] 7 * @param integer $onlymsg [description] 8 * @param integer $limittime [description] 9 * @return [type] [description] 10 */ 11 function _alert($msg, $gourl,$title='',$onlymsg=0, $limittime=0 ) 12 13 { 14 15 if(empty($GLOBALS['cfg_plus_dir'])) $GLOBALS['cfg_plus_dir'] = '..'; 16 17 $htmlhead = "<html> <head> <title>$title</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> "; 18 19 $htmlhead .= "<base target='_self'/> <style>div{line-height:160%;}</style></head> <body> <center> <script> "; 20 21 $htmlfoot = "</script> </center> </body> </html> "; 22 23 //默认3秒返回 24 25 $litime = ($limittime==0 ? 3000 : $limittime); 26 27 $func = ''; 28 29 if($gourl=='-1') 30 31 { 32 33 if($limittime==0) $litime = 3000; 34 35 $gourl = "javascript:history.go(-1);"; 36 37 } 38 39 if($gourl=='' || $onlymsg==1) 40 41 { 42 43 $msg = "<script>alert("".str_replace(""","“",$msg)."");</script>"; 44 45 } 46 47 else 48 49 { 50 51 // 当网址为:close::objname 时, 关闭父框架的id=objname元素 52 53 // if(preg_match('/close::/',$gourl)) 54 55 // { 56 57 // $tgobj = trim(preg_replace('/close::/', '', $gourl)); 58 59 // $gourl = 'javascript:;'; 60 61 // $func .= "window.parent.document.getElementById('{$tgobj}').style.display='none'; "; 62 63 // } 64 65 66 67 $func .= " var pgo=0; 68 69 function JumpUrl(){ 70 71 if(pgo==0){ location='$gourl'; pgo=1; } 72 73 } "; 74 75 $rmsg = $func; 76 77 $rmsg .= "document.write("<br /><div style='300px;padding:0px;border:1px solid #DADADA;'>"; 78 79 $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>"); "; 80 81 $rmsg .= "document.write("<div style='height:130px;background:#fff'>"); "; 82 83 $rmsg .= "document.write("<div style='padding:16px 5px 5px;color:000;font-size:16px;'>".str_replace(""","“",$msg)."</div>"); "; 84 85 $rmsg .= "document.write(""; 86 87 88 89 if($onlymsg==0) 90 91 { 92 93 if( $gourl != 'javascript:;' && $gourl != '') 94 95 { 96 97 // $rmsg .= "<br /><a href='{$gourl}'>如果你的浏览器没反应,请点击这里...</a>"; 98 $rmsg .= "<div style='padding-top:10px;'><a href='{$gourl}'><button style='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>"; 99          // IE不兼容button 可直接用a链接
               //$rmsg .= "<a href='{$gourl}' style='text-decoration: none;color:#fff;'><div style='padding-top:0px;80px;height:30px;line-height:30px; background-color: #DE5923;border:0; font-size:14px;cursor: pointer; border-radius: 2px;'>确定</div></a>"; 100 $rmsg .= "<br/></div>"); "; 101 102 $rmsg .= "setTimeout('JumpUrl()',$litime);"; 103 104 } 105 106 else 107 108 { 109 110 $rmsg .= "<br/></div>"); "; 111 112 } 113 114 } 115 116 else 117 118 { 119 120 $rmsg .= "<br/><br/></div>"); "; 121 122 } 123 124 $msg = $htmlhead.$rmsg.$htmlfoot; 125 126 } 127 128 echo $msg; 129 130 } 131 132 // _alert('对不起,你的信息不完整的啊!风刀霜剑韩复榘恐慌房价', ' ',$title='小鬼PSer提示:',' ','1000000');

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

  • 相关阅读:
    网易云信Duilib开发实践和Windows应用界面开发框架源码开源介绍
    WebRTC 之ICE浅谈
    如何做好 Android 端音视频测试?
    技术详解:实现互动直播全过程
    视频直播技术:最大限度保障流畅性和清晰度
    Python 爬虫之request+beautifulsoup+mysql
    Python之Mysql实战
    Python多线程的效率
    Python 调用Jenkins API自动化发布服务(完整版)
    Python爬虫之request +re
  • 原文地址:https://www.cnblogs.com/php-qiuwei/p/7611632.html
Copyright © 2011-2022 走看看