因此,当新访客到达网站时,起始图像将是" background3.jpg"而不是开始" background1.jpg"
在下面,您可以看到我在索引页面上使用的脚本,该脚本控制幻灯片。
<script>
$.backstretch([
"imgs/background1.jpg",
"imgs/background2.jpg",
"imgs/background3.jpg",
"imgs/background4.jpg",
"imgs/background5.jpg" ], {
fade: 800, //Speed of Fade
duration: 2500 // The length of Time the image is display
});
答案 0 :(得分:0)
您可以测试cookie是否存在:
if($.cookie(cookie_name)){
$.backstretch(
"imgs/background1.jpg",
"imgs/background2.jpg",
"imgs/background3.jpg",
"imgs/background4.jpg",
"imgs/background5.jpg", {
fade: 800, //Speed of Fade
duration: 2500 // The length of Time the image is display
});
} else {
//your server sends the cookies here
dont_show_slides();
}
答案 1 :(得分:0)
在此处下载jquery-cookie插件:link
<script>
$(document).ready(function(){
if($.cookie("IsNew").length==0){
$.cookie("IsNew","somevalue");
$.backstretch(["imgs/background1.jpg",
"imgs/background2.jpg",
"imgs/background3.jpg",
"imgs/background4.jpg",
"imgs/background5.jpg"],
{fade: 800, duration :2500 });
}
else
{
$.backstretch(["imgs/background3.jpg",
"imgs/background1.jpg",
"imgs/background2.jpg",
"imgs/background4.jpg",
"imgs/background5.jpg"],
{fade: 800, duration :2500 });
}
});
</script>