《PHP實例:Thinkphp5結合layer彈窗定制操作結果頁面》要點:
本文介紹了PHP實例:Thinkphp5結合layer彈窗定制操作結果頁面,希望對您有用。如果有疑問,可以聯(lián)系我們。
相關主題:thinkphp教程
PHP學習本文實例為大家分享了Thinkphp5結合layer彈窗定制頁面的具體代碼,供大家參考,具體內(nèi)容如下
PHP學習1 打開應用公共文件頁面??? appliction/common.php,編寫以下代碼
PHP學習注意: 成功消息的綠色背景部分是iframe 框架寫法,如果是普通頁面.就吧parent去除,改為: self.location.href="'.$url.'" rel="external nofollow" rel="external nofollow"
PHP學習
/**
* $msg 待提示的消息
* $url 待跳轉的鏈接
* $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;
}
PHP學習2 使用實例:
PHP學習
public function test(){
return alert_error('您好,歡迎光顧來到博客園');
}
public function test(){
return alert_success('您好,歡迎來到博客園!','http://www.cnblogs.com');
}
PHP學習?3 效果:
PHP學習
PHP學習以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持維易PHP.
轉載請注明本頁網(wǎng)址:
http://www.snjht.com/jiaocheng/513.html