初次加载后关闭启动屏幕

Turn off Splash screen after initial load

本文关键字:启动 屏幕 加载      更新时间:2023-09-26

目前对于一个网站,我有index.html、about.html等。启动屏幕加载在index.html上,但我不希望它在最初加载到主屏幕后再出现。(甚至从关于页面->索引)

这是我的jquery:

$(document).ready(function() {
    if ($(".splash").is(":visible")) {
        $(".wrapper").css({"opacity":"0"});
    }
    $(".splash-arrow").click(function() {
        $(".splash").slideUp("800", function() {
            $(".wrapper").delay(100).animate({"opacity":"1.0"}, 800);
        });
    });
});

它已连接到index.html。关于如何解决这个问题,有什么建议吗?

如果只想在用户第一次访问index.html时显示启动屏幕,则需要将该信息存储在某个位置。通常,这是通过LocalStorageCookies来完成的。对于后者,github上有一个优秀的库:

js cookie。

请记住,Cookie会随您提出的每一个请求一起发送回服务器。

样本代码:

$(document).ready(function() {
    if (typeof Cookies.get("seen_splash") !== "undefined") {
        // Insert code to show the splash screen here
    }
    // Set the cookie for 365 days.
    $(".splash-arrow").on("click", function() {
        Cookies.set("seen_splash", true, { expires: 365 });
    });
});