我正在使用本教程在我的网站上创建弹出消息:LINK
它应该只显示/弹出,当用户使用 IE7 或更少时,并且只有一次 - 所以我需要使用 cookie。
本教程使用了一个名为“Reveal”的 jQuery 插件,它的激活方式如下:
<script type="text/javascript">
$(document).ready(function() {
$('#button').click(function(e) { // Button which will activate our modal
$('#modal').reveal({ // The item which will be opened with reveal
animation: 'fade', // fade, fadeAndPop, none
animationspeed: 600, // how fast animtions are
closeonbackgroundclick: true, // if you click background will modal close?
dismissmodalclass: 'close' // the class of a button or element that will close an open modal
});
return false;
});
});
该脚本附带的 HTML 是这样编写的:
<div id="modal">
<div id="heading">
Are you sure you want to do that?
</div>
<div id="content">
<p>Clicking yes will make Comic Sans your new system<br> default font. Seriously, have you thought this through?</p>
<a href="#" class="button green close"><img src="images/tick.png">Yes, do it now!</a>
<a href="#" class="button red close"><img src="images/cross.png">No, I’m insane!</a>
</div>
</div>
我尝试"Reveal"-plugin
使用THIS脚本自己将 cookie 添加到 ,但没有运气:
<script type="text/javascript">
$(document).ready(function() {
if ( $.cookie ( 'first_visit' ) !== '0' ){
$('#modal').reveal({ // The item which will be opened with reveal
animation: 'fade', // fade, fadeAndPop, none
animationspeed: 600, // how fast animtions are
closeonbackgroundclick: true, // if you click background will modal close?
dismissmodalclass: 'close' // the class of a button or element that will close an open modal
});
$.cookie( 'first_visit' , '0' );
return false;
}
});
</script>
我究竟做错了什么?我希望此弹出消息显示在 IE7 及以下版本 - 仅在第一次访问该站点时。