What I do is use style. Say your div has an id - "overlay":
Code:
<style type="text/css">
#overlay {
display: none;
}
</style>
Then one of the first things in your script could be:
Code:
document.write('<style type="text/css">#overlay {display: block;}<\/style>');
As long as the script follows the style and both are in the head, it will produce valid code. If javascript is enabled, the scripted style will override the hard coded one and the overlay will be seen. If javascript is unavailable, the hard coded one is the only one the browser will see, so the overlay will not be shown.
Many people prefer to use the onload or document ready event to reveal javascript only elements like this. However, that often takes too long. Doing it this way is just like having it hard coded, no waiting for the page to load.
Bookmarks