[英]Display fancybox on page load per session
使用fancyBox v2和jQuery Cookie插件。
碼:
var check_cookie = $.cookie('the_cookie');
if(check_cookie == null){
$.cookie('the_cookie', 'the_value');
$("#hidden_link").fancybox().trigger('click');
}
有用。 但是我想要,當我關閉網站或瀏覽器並返回時,再次顯示fancybox。 嘗試過此方法但不起作用:
var check_cookie = $.cookie('the_cookie');
if(check_cookie == null){
$("#hidden_link").fancybox().trigger('click'), {
'onComplete' : function() {
$.cookie('the_cookie', 'the_value');
}
});
}
通過DevTools檢查,得到此錯誤:
Uncaught SyntaxError: Unexpected token ) on 42.
42. line:
});
我該如何解決?
在分配時將時間范圍設置為Cookie,可以說30分鍾
var check_cookie = $.cookie('the_cookie');
if(check_cookie == null){
$.cookie('the_cookie', 'the_value', { expires: 30 * 60 * 1000 });
$("#hidden_link").fancybox().trigger('click');
}
請參考以下鏈接。
這是一個簡單的語法錯誤。 onComplete
是fancybox的API選項,因此它位於fancybox函數內部,例如
var check_cookie = $.cookie('the_cookie');
if (check_cookie == null) {
$("#hidden_link").fancybox({
'onComplete': function () {
$.cookie('the_cookie', 'the_value');
}
}).trigger('click');
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.