目前对于一个网站,我有 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
时显示初始屏幕,您需要将该信息存储在某处。通常这是通过 LocalStorage
或 Cookies
完成的。对于后者,github 上有一个优秀的库可用:
请记住,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 });
});
});
关于javascript - 初始加载后关闭启动画面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36898810/