Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-12-2013, 09:05 PM   PM User | #1
durangod
Senior Coder

 
Join Date: Nov 2010
Posts: 1,177
Thanks: 214
Thanked 31 Times in 30 Posts
durangod is on a distinguished road
Loading indicator question

I am doing a loader indicator (image with some text next to it) while the page loads.

But im not having so much success with it.

right after the body tag i have this

Code:
<div id="loading-mask"></div> 
 <div id="loading">
   <div class="loading-indicator"></div>
 </div>

Then right after that i have the js

Code:
<script type="text/javascript">
document.getElementById('loading-indicator').innerHTML = 'Loading file...';
</script>
The issue is that it comes up and displays but it just sits there, it does not end and load the page.

Not sure what i am mssing here or maybe i dont have this in the right place in the file. Should it go on the very bottom of the file?

Last edited by durangod; 02-12-2013 at 09:48 PM..
durangod is offline   Reply With Quote
Old 02-12-2013, 09:21 PM   PM User | #2
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,387
Thanks: 18
Thanked 350 Times in 349 Posts
sunfighter is on a distinguished road
Code:
document.getElementById('loading-indicator').innerHTML = 'Loading file...';
loading-indicator is not an ID it's a class.

And don't see where your loading anything. Is that somewhere else?
sunfighter is offline   Reply With Quote
Users who have thanked sunfighter for this post:
durangod (02-12-2013)
Old 02-12-2013, 09:29 PM   PM User | #3
durangod
Senior Coder

 
Join Date: Nov 2010
Posts: 1,177
Thanks: 214
Thanked 31 Times in 30 Posts
durangod is on a distinguished road
good eye i was cleaning it up and i removed the span because i had my own message and i honestly did not realize it was the id it should look like this


same js as above but this is dif

Code:
<div id="loading-mask"></div>
 <div id="loading">
    <div class="loading-indicator">
     <span id="loading-indicator">Loading. Please wait...</span>
    </div>
  </div>

see any issues here ?
durangod is offline   Reply With Quote
Old 02-12-2013, 09:44 PM   PM User | #4
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,043
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
This may be useful:-


Code:
<html>
<head>

<style type = "text/css">
.styling{
background-color:black;
color:red;
font: bold 24px MS Sans Serif;
padding: 6px;
}
</style>

</head>


<body onload = "showLoad()">

<br><br>
<center>
<span id = "a" class = "styling"></span>
</center>

<script type = "text/javascript">
var num = 0;  
var tim;
var txt = "Loading, please wait ........";
document.getElementById("a").innerHTML = txt;

function showLoad() {
num ++;
if (num == 5) {  // erase after 5 seconds, adjust to suit
document.getElementById("a").style.display="none";
window.clearTimeout(tim);
}
else {
tim = window.setTimeout("showLoad()", 1000);
}
}

</script>


</body>
</html>
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Users who have thanked Philip M for this post:
durangod (02-12-2013)
Old 02-12-2013, 09:47 PM   PM User | #5
durangod
Senior Coder

 
Join Date: Nov 2010
Posts: 1,177
Thanks: 214
Thanked 31 Times in 30 Posts
durangod is on a distinguished road
thanks all..
durangod is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:11 PM.


Advertisement
Log in to turn off these ads.