欢迎正在加载...带有 Jquery 的页面

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/955746/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 10:14:04  来源:igfitidea点击:

Welcome Loading ... Page with Jquery

jquery

提问by Sumanta

How can I implement a welcome screen for 5 seconds giving information like Loading application ... + some application infos...while the main page loads in background.

我如何实现一个 5 秒的欢迎屏幕,提供诸如加载应用程序... + 一些应用程序信息...而主页面在后台加载等信息。

采纳答案by jonstjohn

I think it is acceptable to have a 'loading ...' page in some cases - for example, after a user to a business application logs in (think TurboTax online ... it says something like 'establishing a secure connection', which is probably not exactly true, but loading interface stuff). Showing the page every time an anonymous user goes to your site is probably not the best idea.

我认为在某些情况下有一个“正在加载......”页面是可以接受的 - 例如,在用户登录业务应用程序后(想想 TurboTax 在线......它说的是“建立安全连接”,这可能不完全正确,但加载界面内容)。每次匿名用户访问您的网站时都显示该页面可能不是最好的主意。

Take a look at jQuery BlockUI. It is flexible and can do what you are talking about.

看看jQuery BlockUI。它很灵活,可以做你在说什么。

回答by Jason

just for anyone in the future who finds this, i found a more elegant solution that works.

只是对于将来发现这一点的任何人,我找到了一个更优雅的解决方案。

http://www.jnorton.co.uk/blog/jquery-check-if-all-content-has-been-loaded

http://www.jnorton.co.uk/blog/jquery-check-if-all-content-has-been-loaded

here is how i used it:

这是我如何使用它:

$(document).ready(function(){
    $(window).load(function() {$("#welcome").fadeOut('fast'); })
});

回答by TheTXI

Unless you are actually using that time in the background to actually do some sort of preloading, I would highly suggest against this coming from an end-user perspective. I personally would find it annoying that when going to a website, I would have to sit through some sort of introduction before actually getting to the content I want.

除非您实际上是在后台使用这段时间来实际进行某种预加载,否则我强烈建议不要从最终用户的角度这样做。我个人会觉得在访问网站时很烦人,在真正访问我想要的内容之前,我必须先阅读一些介绍。

This is why I tend to hate websites designed in Flash or those that simply incorporate a Flash splash page.

这就是为什么我倾向于讨厌用 Flash 设计的网站或那些只包含 Flash 启动页面的网站。

Edit: I don't necessarily think the main page's load should qualify for much on the "preloading" scale, unless it is resource intensive. Again, these are just my opinions.

编辑:我不一定认为主页的加载应该符合“预加载”规模的要求,除非它是资源密集型的。同样,这些只是我的意见。

Edit #2: It could also be argued that visitors to your website will make their decision on whether to stay or go based on as little as five seconds. Remember that those using the internet tend to have the attention spans of fruit flies, and putting them into a holding pattern before they actually get to the content is a good way to lose those users.

编辑 #2:也可以说,您网站的访问者会在短短五秒钟内决定是留下还是离开。请记住,那些使用互联网的人往往拥有果蝇的注意力,在他们真正接触到内容之前将他们置于一种保持模式是失去这些用户的好方法。

回答by Justin Niessner

You would show your welcome message as the page loads (theoretically as an absolutely positioned overlay). You could then use jQuery to kick off a timer:

您将在页面加载时显示您的欢迎信息(理论上作为绝对定位的叠加层)。然后,您可以使用 jQuery 来启动计时器:

$(document).ready(function(){
    setTimeout(function(){
        $('div#overlay').fadeOut();
    }, 5000);
});

回答by ANaimi

Although I agree with @TheTXI, the best way to do it is to have the "loading..." screen visible by default using CSS, and then hide it once everything is loaded using jQuery (instead of waiting for a fixed amount of time).

尽管我同意@TheTXI,但最好的方法是使用 CSS 默认显示“正在加载...”屏幕,然后在使用 jQuery 加载所有内容后隐藏它(而不是等待固定的时间)。

See jQuery.load()... ex:

参见jQuery.load()... 例如:

  $(document).ready(function(){
    $("body img:last").load($("#welcome-screen").fadeOut());
  });