0
我想檢查cookie是否存在,然後在javascript中創建cookie並觸發colorbox.inside顏色框需要加載在php.now中創建的div顏色不是觸發。檢查cookie是否設置爲javascript
PHP
if(!isset($_COOKIE['first_time'])) {
echo '<div class="celebration-popup"><img src="'. base_path() . $directory.'/img/birthdayTemplate.jpg">/div>';
}
的JavaScript
if (document.cookie.indexOf("first_time=") == 0){
expiry = new Date();
expiry.setTime(expiry.getTime()+(0.5*60*1000)); // 30 seconds
document.cookie = "first_time=yes; expires=" + expiry.toGMTString();
jQuery.colorbox({
inline: true,
href: ".celebration-popup",
onClosed: function() {
jQuery(".celebration-popup").hide()
}
});
}