Created
May 18, 2017 17:00
-
-
Save lizardking8610/c58ff6cfd8c217810d756000b8e8b364 to your computer and use it in GitHub Desktop.
jQuery: display loading graphic while page renders
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html class="no-js"> | |
| <head> | |
| <meta charset='UTF-8'> | |
| <title>Simple Loader</title> | |
| <style> | |
| /* This only works with JavaScript, | |
| if it's not present, don't show loader */ | |
| .no-js #loader { display: none; } | |
| .js #loader { display: block; position: absolute; left: 100px; top: 0; } | |
| </style> | |
| <script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script> | |
| <script src="https://github.com/Modernizr/Modernizr/raw/master/modernizr.js"></script> | |
| <script> | |
| // Wait for window load | |
| $(window).load(function() { | |
| // Animate loader off screen | |
| $("#loader").animate({ | |
| top: -200 | |
| }, 1500); | |
| }); | |
| </script> | |
| </head> | |
| <body> | |
| <img src="download.png" id="loader"> | |
| <img src="//farm6.static.flickr.com/5299/5400751421_55d49b2786_o.jpg"> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment