Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Preloading a message while page loads

Status
Not open for further replies.

kehers

Programmer
Aug 31, 2005
56
A2
using the following snippet to intimate a user that a certain task is been going on while the page loads :
Code:
<script type="text/javascript">
<!-- Begin
document.write('<div id="loading">task going on eg. Searching, please wait...
</div>');
window.onload=function(){
document.getElementById("loading").style.display="none";
}
// End -->
</script>
it works quite well but when i tried adding a flash animation in between the <div> tags(in palce of task going on eg. Searching, please wait..., it doesnt work..any idea wat could be wrong or how to go about it?
 
Rather, instead of using javascript to document.write this... just put the div onto the page normally! The flash code you are using may require this (in your instance).

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]

What is Javascript? faq216-6094
 
Sorry...i forgot to mention the script is in within the hed tag...guess thats wat makes it show the message while the page loads...putting the flash code directly inside the body, i guess, wont work..however, its worth a try.
 
Think about what the code is doing. As the page is being delivered, the browser sees a script section in the head part of the document. It then runs the script (since it's all inline) and faithfully writes out the div... right in the middle of the head section. Does this sound right to you? No.

Here is what I was getting at in my initial reply:
Code:
<html>
<head>
<script>...</script>
</head>
<body onload="document.getElementById('loading').style.display='none'">
<div id="loading">Loading...</div>
...
</body>
</html>
You would then place your flash code in place of the "loading..." text in the div.

Give it a try and see if that works for you.

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]

What is Javascript? faq216-6094
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top