我真的是 Jquery 的新手,我发现了几个使用 cookie 和 onload 功能打开灯箱的示例。我正在使用与 fancybox 一起使用的 cookie 示例,但我一直在我的所有网站上使用 prettyPhoto,并且真的不想更改为 fancybox。我已经尝试了十几种不同的方法来让它工作,但我没有运气。这是我的代码。任何帮助或建议都会很棒。
$(文档).ready(函数(){
// !!! SEE THIS PLEASE !!!
// delete this line to make the modal box load only ONCE
// if you let it set to 'false' it will show every time .. set it to 'true' and it will never show
$.cookie("modal", 'false')
/**
* MODAL BOX
*/
// if the requested cookie does not have the value I am looking for show the modal box
if($.cookie("modal") != 'true')
{
alert("sometext");
var where = "http://images.motortrend.com/photo_gallery/112_0611_39z+2006_bugatti_veyron+interior.jpg"; var 标题 = ""; var 评论 = "";
function showLbox(){ $.prettyPhoto.open(where, title, comment); } // 在页面加载时显示模态框 // 有关您可以在 fancybox 网站上找到的选项的更多信息
// in the message is a link with the id "modal_close"
// when you click on that link the modal will close and the cookie is set to "true"
// path "/" means it's active for the entire root site.. if you set it to "/admin" will be active on the "admin" folder
// expires in 7 days
// "modal" is the name i gave the cookie.. you can name it anything you want
$('#modal_close').live('click', function(e) {
e.preventDefault();
$.cookie("modal", "true", { path: '/', expires: 7 });
});
}
});