【问题标题】:Creating a splash page in HTML5在 HTML5 中创建启动页面
【发布时间】:2013-12-29 18:49:45
【问题描述】:

我想为我正在使用 HTML5 创建的应用程序创建一个启动页面。 splash page 应该在 ma​​in page 正在加载时显示(但显示应该至少 2 秒,即使 main page 已经加载)。假设我的主页名为main.html,启动页面名为index.html

我是 JavaScript 新手,所以我非常感谢代码示例以及任何解释。

谢谢!

【问题讨论】:

  • 加载启动画面,两秒钟后开始检查是否加载了主页。尽快关闭飞溅。

标签: javascript html splash-screen


【解决方案1】:

你可以这样做:

<!DOCTYPE html>
<html>
    <head>
        <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
        <script type="text/javascript">
            $('#splash').ready() 
            {
                $('#main').load('file.html');
                setTimeout(function() {
                    $('#main').ready(function() {
                        $('#splash').remove();
                        window.location.href = "file.html";
                    });
                }, 2000);
            }
        </script>
    </head>
    <body>
        <div id="splash" style="position: absolute; top: 0px; bottom: 0px; left: 0px; right: 0px; z-index: 10;">
            <!--Put splash here-->
        </div>
        <div id="main">
            <!-- keep empty -->
        </div>
    </body>
</html>

未经过真正测试,可能包含错误... 使用 jQuery

【讨论】:

  • 谢谢你,调试你的代码帮助我提高了我的java脚本技能,我也得到了我需要的东西! :-)
  • 他写了java脚本
猜你喜欢
  • 1970-01-01
  • 2019-08-07
  • 1970-01-01
  • 1970-01-01
  • 2013-10-15
  • 2020-02-27
  • 1970-01-01
  • 1970-01-01
  • 2016-12-11
相关资源
最近更新 更多