我对Jquery真的很陌生,我发现了几个使用cookie和onload功能打开灯箱的例子。我正在使用与fancybox一起使用的cookie示例,但我一直在我的所有网站上使用prettyPhoto,并且确实不想更改为fancybox。我尝试了十几种不同的方式来使这个工作,但我没有运气。这是我的代码。任何帮助或建议都会很棒。如何在页面加载时自动打开prettyPhoto lightbox?
$(文件)。就绪(函数(){
// !!! 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其中= “http://images.motortrend.com/photo_gallery/112_0611_39z+2006_bugatti_veyron+interior.jpg”; 变种标题= “”; VAR评论= “”;
功能showLbox(){$ .prettyPhoto.open(其中,标题,评论);} // 在页面加载显示模式对话框 //有关您可以找到的选项的更多信息fancybox site
// 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 });
});
}
});
请修复您的代码标签:) – Bjorn 2010-09-24 20:41:54