This article is about how to create a simple loading bar. Actually, the loading progress of a page could be got. But in this article, I only use a simple way to implement the loading bar.
Prepare
First, create a html file. Like this:
1  | 
  | 
Then add some CSS inhead section.
1  | <style>  | 
Now the whole html file looks like this:
1  | 
  | 
Create Javascript function
Now, we need to add some Javascript function just under the progress container. As after rendering the progress-container, the broswer will run the javascript file before rendering any other elements.
1  | <script>  | 
Testing
Now add some iframe to the html page for testing purpose
1  | 
  | 
See the Pen GEqvxv by YI YANG (@yanniyiyi) on CodePen.