Thinkphp5結(jié)合layer彈窗定制操作結(jié)果頁面
本文實例為大家分享了Thinkphp5結(jié)合layer彈窗定制頁面的具體代碼,供大家參考,具體內(nèi)容如下
1 打開應(yīng)用公共文件頁面 appliction/common.php,編寫以下代碼
注意: 成功消息的綠色背景部分是iframe 框架寫法,如果是普通頁面。就吧parent去除,改為: self.location.href="'.$url.'" rel="external nofollow" rel="external nofollow"
/** * $msg 待提示的消息 * $url 待跳轉(zhuǎn)的鏈接 * $icon 這里主要有兩個,5和6,代表兩種表情(哭和笑) * $time 彈出維持時間(單位秒) */ function alert_success($msg='',$url='',$time=3){ $str='<script type="text/javascript" src="/static/admin/lib/jquery/1.9.1/jquery.min.js"></script> <script type="text/javascript" src="/static/admin/lib/layer/2.4/layer.js"></script>';//加載jquery和layer $str.='<script> $(function(){ layer.msg("'.$msg.'",{icon:"6",time:'.($time*1000).'}); setTimeout(function(){ self.parent.location.href="'.$url.'" rel="external nofollow" rel="external nofollow" },2000) }); </script>';//主要方法 return $str; } /** * $msg 待提示的消息 * $icon 這里主要有兩個,5和6,代表兩種表情(哭和笑) * $time 彈出維持時間(單位秒) */ function alert_error($msg='',$time=3){ $str='<script type="text/javascript" src="/static/admin/lib/jquery/1.9.1/jquery.min.js"></script> <script type="text/javascript" src="/static/admin/lib/layer/2.4/layer.js"></script>';//加載jquery和layer $str.='<script> $(function(){ layer.msg("'.$msg.'",{icon:"5",time:'.($time*1000).'}); setTimeout(function(){ window.history.go(-1); },2000) }); </script>';//主要方法 return $str; }
2 使用實例:
public function test(){ return alert_error('您好,歡迎光顧來到博客園'); } public function test(){ return alert_success('您好,歡迎來到博客園!','http://www.cnblogs.com'); }
3 效果:
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
php之XML轉(zhuǎn)數(shù)組函數(shù)的詳解
本篇文章是對php中的XML轉(zhuǎn)數(shù)組函數(shù)進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06thinkphp驗證碼的實現(xiàn)(form、ajax實現(xiàn)驗證)
這篇文章主要介紹了thinkphp驗證碼的實現(xiàn)(form、ajax使用驗證)的相關(guān)資料,需要的朋友可以參考下2016-07-07php使用wangeditor實現(xiàn)富文本遇見問題及兩種解決方法
在?PowerShell?中使用?npm?install?命令時,命令行解析器可能會將?@?符號解釋為特殊字符,導(dǎo)致出現(xiàn)錯誤,遇到這樣的問題如何解決呢,下面通過本文介紹php使用wangeditor實現(xiàn)富文本-遇見問題,需要的朋友可以參考下2023-12-12php實現(xiàn)微信小程序授權(quán)登錄功能(實現(xiàn)流程)
這篇文章主要介紹了php實現(xiàn)微信小程序授權(quán)登錄功能,本文通過一段詳細(xì)的代碼給大家講解的非常詳細(xì),需要的朋友參考下2019-11-11Laravel5中實現(xiàn)模糊匹配加多條件查詢功能的方法
這篇文章主要介紹了Laravel5中實現(xiàn)模糊匹配加多條件查詢功能的方法,結(jié)合實例形式分析了Laravel5多條件模糊查詢及相關(guān)封裝操作技巧,需要的朋友可以參考下2018-03-03