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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

anti-document.write clearing?

Status
Not open for further replies.

MikeBarone

Programmer
Joined
Mar 1, 2001
Messages
354
Location
US
Does anyone know how you get the document.write() method to _not_ clear the screen when you go to write? Everytime I've tried to use document.write, it clears the page to write the new text.

Thanks.
Mike Barone
FREE CGI/Perl Scripts & JavaScript Generators
Ace PopUp Generator Software - Totally FREE
 
Howdy,

The document.write() function has only one chance to run, and this is whilst the document is being rendered in the browser window.

During the rendering the document is said to be "open", and when the rendering finishes the document "closes". This happens automatically once during initial page loading, but can also be done explicitly at any other time using document.open() and document.close().

When you call the document.write() function while the document is closed, (i.e. in response to an event or something) you are supposed to first open the document with document.open(). This wipes the document clean and allows new content to be written to it.

If you don't use document.open() first, it is called implicitly and executes anyway. Thus, the window is always cleared.

Afterwards, use document.close() to complete the process or else the stuff you wrote may not appear at all.

Usually when you use document.write(), make sure it runs while the page is still loading. (open) Then it should work as expected, and open/close need not be used.

I hope this answers your questions about document.write().

Cheers,
Petey
 
hie
>>petey:
your suggestion doesnt works for me (ie5.0, nn4.61)
i now that it works with layers in netscrap, but i cant get it to work for the hole document for now...
 
and Mike, is it still about your prev posts? i thought i explained it 2 ya... :((
 
No, this is something totally new. The other thing worked GREAT! Thanks again! Mike Barone
FREE CGI/Perl Scripts & JavaScript Generators
Ace PopUp Generator Software - Totally FREE
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top