Loading bar can be achieve with the help of window load event. The load event is fired when the whole page has loaded, including all dependent resources such as stylesheets and images.
Let's understand it with the help of an example :
<!DOCTYPE html>
<html lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta charset='utf-8' />
<title>Asynchronous JavaScript </title>
<script>
window.onload = function () {
// PAGE IS FULLY LOADED
// FADE OUT YOUR OVERLAYING DIV
var fadeTarget = document.getElementById('overlay');
fadeTarget.style.opacity = 0.1;
};
</script>
</head>
<body align='center'>
<div id='overlay'>
<img src='loading.gif' alt='Loading' />
Loading...
</div>
</body>
</html>
Hope this information has cleared your confusion.
Happy Coding!
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Loading bar can be achieve with the help of window load event. The load event is fired when the whole page has loaded, including all dependent resources such as stylesheets and images.
Let's understand it with the help of an example :
Hope this information has cleared your confusion.
Happy Coding!