- document.write() is evil because it affects the document as it's been
rendered. There are some (very,very few) instances when you might need
to do this.
I have used it recently to change a form on the client side depending on
document.writeln("<input id='contactFormSend' disabled='disabled'
value='Send Request' type='submit' />");
<input value="Send Request" type="submit" />
This isn't something that can easily be done on the server and allows
sent - at least, when the page was loaded. The server uses this to
determine the likelihood that the form has had minimal validation or
none at all and warn the user.
Using document.write or document.writeln as a debugging measure is
asking for trouble. Until recently (hang my head in shame) I relied on
Alert() or some concoction of DIVs. <shudders>
A far better solution is Firefox with the Firebug extension. Firebug can
write to a special console area:
console.log(var1, var2, object, ...);
and is very, very good at it too. You can even examine events objects
(for example) just by passing them like this:
Firebug allows you to decompose the entire event, method by property in
the console window which can be very handy indeed.