試圖顯示這個彈出每次訪問一次。我覺得我失去了一些東西顯示彈出一次(蕩氣迴腸彈出)
<script src="http://code.jquery.com/jquery-1.7.min.js">
<link href="http://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.css" rel="stylesheet" type="text/css" media="all"/>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.0/jquery.cookie.js"></script>
<script>
$(document).ready(function() {
var check_cookie = $.cookie('bsw');
if(check_cookie == null){
$.cookie('bsw', 'yes', {expires: 1 });
$('.image-link').magnificPopup({type:'image'});
});
</script>
<script>
(function($) {
$(window).load(function() {
// retrieved this line of code from http://dimsemenov.com/plugins/magnific-popup/documentation.html#api
$.magnificPopup.open({
items: {
src: '/bsw-10-off.png'
},
type: 'image'
// You may add options here, they're exactly the same as for $.fn.magnificPopup call
// Note that some settings that rely on click event (like disableOn or midClick) will not work here
}, 0);
});
})(jQuery);
</script>
我沒有關閉或打開一些東西嗎?我覺得這個問題在文檔準備好的功能之內,但我可能是錯的。任何幫助,將不勝感激。謝謝。
下面是一個沒有Cookie代碼的代碼
<link href="http://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.css" rel="stylesheet" type="text/css" media="all"/>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.min.js"></script>
<script>
$(document).ready(function() {
$('.image-link').magnificPopup({type:'image'});
});
</script>
<script>
(function($) {
$(window).load(function() {
// retrieved this line of code from http://dimsemenov.com/plugins/magnific-popup/documentation.html#api
$.magnificPopup.open({
items: {
src: 'http://www.barbershopwindow.com/bfimages/bsw-10-off.png'
},
type: 'image'
// You may add options here, they're exactly the same as for $.fn.magnificPopup call
// Note that some settings that rely on click event (like disableOn or midClick) will not work here
}, 0);
});
})(jQuery);
</script>
你從來沒有提到什麼是不工作的。 –
首先,你的Cookie代碼中的'if'有一個丟失的大括號。 –
問題是它不斷出現 – MHeredia