javascript - Creating a splash page in HTML5 - Stack Overflow

I want to create a splash page for the app I'm creating using HTML5.The splash page should be dis

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745142237a4613482.html

相关推荐

  • javascript - Creating a splash page in HTML5 - Stack Overflow

    I want to create a splash page for the app I'm creating using HTML5.The splash page should be dis

    5小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信