should I use document.write()?

J

Jivanmukta

Hello,
I am learning JavaScript and I have a question:
I have read somewhere in Internet that document.write() should not be
used.
Is this true? Why?
Thanks for information.
 
D

David Mark

Jivanmukta said:
Hello,
I am learning JavaScript and I have a question:
I have read somewhere in Internet that document.write() should not be
used.

You'll find lots of ill-conceived generalizations on the Internet. Just
recently I read that you should not put SCRIPT elements in the BODY as
it would make some unnamed "progressive enhancement" people mad. :)
Is this true? Why?

No, the generalization is not true. It's not true because there can be
good reasons for using document.write, particularly where the
alternatives are completely unworkable (e.g. synchronous XHR--see Dojo).
Personally, I find it useful to inject style sheets to prevent FoUC.
Of course, there are alternative workable ways to do that, but not
nearly as compatible.
Thanks for information.

NP.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,079
Messages
2,570,574
Members
47,207
Latest member
HelenaCani

Latest Threads

Top