2015-08-25 76 views
1

我已經使用jquery的fadeOut選項創建了啓動畫面。它工作正常,但問題是屏幕加載每次我點擊進入下一頁。 我只在啓動時需要啓動畫面。 我想我需要使用會話或其他方式,但我無法找到解決方案。 我正在使用以下腳本。在啓動時只加載一次啓動畫面php

$(document).ready(function() { 
$("#splashscreen").click(function() { 
    $("#splashscreen").fadeOut(2000); 
}); 
}); 

回答

5

這應該工作:

$(document).ready(function() { 
    if($.cookie('splashscreen') == null) { // Here you are checking if cookie is existing if not you are showing a splash screen and set a cookie 
     $("#splashscreen").fadeIn(); 
     $.cookie("splashscreen", 1, { expires : 10 }); // cookie is valid for 10 days 
    } 
    $("#splashscreen").click(function() { 
     $("#splashscreen").fadeOut(2000); 
    }); 
}); 
+0

非常感謝。我在其他部分添加了css display none屬性,並且似乎正在工作。 – RakeshShrs

0

是的,你可以使用這個會話。在你的代碼的第一行添加<?php session_start();

現在,後面的代碼中,你可以這樣做:

if(!$_SESSION['splash']) 
{ 
    $_SESSION['splash'] = true; 

    //echo your splash code here 
}