Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- document.getElementById vs document.write?


Fotiman - 2:32 pm on Nov 13, 2012 (gmt 0)



If it must be done prior to page onload use write() after onload use getElementById or similar.

That is bad advice. Avoid document.write at all times. It's considered bad practice, and there are cleaner alternatives.

document.write leads to poor coding habits, like mixing behavior code with content. In your case, you might consider doing something like this:

Design for the base case (JavaScript disabled) and treat this for what it is... progressive enhancement. For example, give your <html> element a class like "no-js", then a script early in your <head> element can change that class value if JavaScript is enabled. Then you can define your presentation such that if there is no JavaScript, the "loading" message is never shown, else it is:

.no-js #loading { display: none; }

Then within your content, you include it:

<div id="loading">Loading...</div>

Check out Modernizr [modernizr.com]


Thread source:: http://www.webmasterworld.com/javascript/4518258.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com