最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Creating a splash page in HTML5 - Stack Overflow

programmeradmin1浏览0评论

I want to create a splash page for the app I'm creating using HTML5. The splash page should be displayed while the main page is being loaded (but the display should be at least 2 seconds even if the main page was already loaded). Say my main page is called main.html and the splash page is called index.html

I'm new to JavaScript, so I would really appreciate code example in addition to any explanations.

Thank you!

I want to create a splash page for the app I'm creating using HTML5. The splash page should be displayed while the main page is being loaded (but the display should be at least 2 seconds even if the main page was already loaded). Say my main page is called main.html and the splash page is called index.html

I'm new to JavaScript, so I would really appreciate code example in addition to any explanations.

Thank you!

Share Improve this question edited Jan 3, 2014 at 10:38 DMEM asked Dec 29, 2013 at 18:49 DMEMDMEM 1,6138 gold badges27 silver badges45 bronze badges 1
  • Load the splash popup, and after two seconds start checking if the main page is loaded. As soon it is, close the splash. – Shomz Commented Dec 29, 2013 at 18:53
Add a ment  | 

1 Answer 1

Reset to default 2

You could do something like this:

<!DOCTYPE html>
<html>
    <head>
        <script type="text/javascript" src="http://code.jquery./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>

Not really tested, might contain bugs... Uses jQuery

发布评论

评论列表(0)

  1. 暂无评论