一、通知
二、方法
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/jquery-jgrowl/1.4.1/jquery.jgrowl.min.css" />
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-jgrowl/1.4.1/jquery.jgrowl.min.js"></script>
<!--調用插件-->
<script type="text/javascript">
$(document).ready(function(){
$.jGrowl('訊息通知中心', { life:3000 , position: 'center', speed: 'slow' });
});
</script>
三、先整合至樣板
<link rel="stylesheet" type="text/css" href="<{$smarty.const.WEB_URL}>/class/jGrowl/jquery.jgrowl.min.css" />
<script src="<{$smarty.const.WEB_URL}>/class/jGrowl/jquery.jgrowl.min.js"></script>
<!--調用插件-->
<script type="text/javascript">
$(document).ready(function(){
$.jGrowl('訊息通知中心', { life:3000 , position: 'center', speed: 'slow' });
});
</script>
四、上面只要一進入網站,就會有訊息通知,請問該如何做到,有訊息時網頁才啟動「通知功能」
header("location:admin/index.php");
redirect_header(轉向網址,停留豪秒,訊息);
由於前後台都可以用,所以將此函數放在function.php
###############################################################################
# 轉向函數
###############################################################################
function redirect_header($url = "", $time = 3000, $message = '已轉向!!') {
$_SESSION['redirect'] = "\$.jGrowl('{$message}', { life:{$time} , position: 'center', speed: 'slow' });";
header("location:{$url}");
exit;
}
$_SESSION['redirect']=isset($_SESSION['redirect'])?$_SESSION['redirect']:"";
$smarty->assign("redirect", $_SESSION['redirect']);
$_SESSION['redirect']="";
<{if $redirect}>
<link rel="stylesheet" type="text/css" href="<{$smarty.const.WEB_URL}>/class/jGrowl/jquery.jgrowl.min.css" />
<script src="<{$smarty.const.WEB_URL}>/class/jGrowl/jquery.jgrowl.min.js"></script>
<!--調用插件-->
<script type="text/javascript">
$(document).ready(function(){
<{$redirect}>
});
</script>
<{/if}>
//header("location:admin/index.php");
redirect_header("admin/index.php", 3000, '登入成功!!');
ps:注意後台jquery的位置
//header("location:index.php");
redirect_header("index.php", 3000, '登出成功!!');
<{include file="tpl/redirect_header.html"}>
redirect_header.html
<{if $redirect}>
<link rel="stylesheet" type="text/css" href="<{$smarty.const.WEB_URL}>/class/jGrowl/jquery.jgrowl.min.css" />
<script src="<{$smarty.const.WEB_URL}>/class/jGrowl/jquery.jgrowl.min.js"></script>
<!--調用插件-->
<script type="text/javascript">
$(document).ready(function(){
<{$redirect}>
});
</script>
<{/if}>