MVC如何在页面加载上添加延迟

时间:2015-06-03 21:47:15

标签: javascript jquery html

我的问题非常简单(我想,但是我找不到任何参考,谁想放慢他们的网站速度,对吧?)并且可能听起来很荒谬,但我想要做的就是在页面上设置一个闪屏加载我的网站的主页/索引。 我所做的是在我的页面顶部,我刚为我的启动添加了一个简单的div,并在页面加载时使用javascript来隐藏它。

$(window).bind("load", function () {
// Remove splash screen after load
$('.splash').css('display', 'none')
})

但我的问题是,我的家庭索引加载太快(因为它只是纯文本/ html)因此启动画面只显示.5秒。我想在删除之前至少添加2-3秒,我假设我只需要在$(window).bind中添加一行或两行代码,在执行$('.splash').css('display', 'none')之前暂停几秒钟,但我不知道怎么做或怎么做,请帮忙!谢谢!

2 个答案:

答案 0 :(得分:4)

您可以使用info=in this string, ref=1, and in another, ref=2, ref=1延迟Javascript中的内容,例如:

ref

答案 1 :(得分:1)

超时工作。

$(window).bind("load", function () { // Remove splash screen after load and 3 seconds setTimeout(function() { $('.splash').css('display', 'none') }, 3000); });