Javascript - how do I insert text into a document?

notfred

Lifer
Feb 12, 2001
38,241
4
0
I have a page that uses javascript to write text (using document.write()) to a page when a button is clicked. The problem is that the entire page is replaced wit the result of the document.write() call. How can I do something similar but jsut insert the result of document.write() into the existing document?

Thanks.
 

SpomaMewor

Member
May 31, 2002
71
0
0
I am not that familiar with javascript but i know in most scripting languages there are two ways to open the file. One will append to the end and the other will overwrite. Try looking into something like that. I know with perl it is the difference of > and >>. Hope this is some help.
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
Originally posted by: SpomaMewor
I am not that familiar with javascript but i know in most scripting languages there are two ways to open the file. One will append to the end and the other will overwrite. Try looking into something like that. I know with perl it is the difference of > and >>. Hope this is some help.

Javascript is a web scripting language. I'm not opening any files. I'm modifying a currently open HTML document.
 

screw3d

Diamond Member
Nov 6, 2001
6,906
1
76
You can write into a text field, and use CSS to remove the borders of the text field..

I haven't tried the CSS part but I think it should work.. put something like "border: none;"
 

dgm

Member
May 10, 2004
30
0
0
Try this.

With this technique, you can tightly control where you place the text and even what style it gets.
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
Originally posted by: dgm
Try this.

With this technique, you can tightly control where you place the text and even what style it gets.

Thanks, that was enough to get it working :)
 

MrChad

Lifer
Aug 22, 2001
13,507
3
81
That code (specifically document.all) is IE-specific. This page shows some techniques that work for other browsers as well.