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

document.write ... anywhere ???? 2

Status
Not open for further replies.

SeAL

Programmer
Mar 15, 2001
139
FR
Hi everybody !!

Here's my problem :

I need to be able to change some text in a page with a javascript function.
My problem is that I need to write the new text to a special place with the "document.write" method.
Does anyone know how to do it under NS & IE ???

My vote will goes to TipMaster who can help me ....

Thanks in advance ...

SeAL
 
It is different depending on the browser:

IE4+ is easy:

elementid.innerHTML = &quot;Some new text and <b>HTML</b>&quot;

NS4 is very limited, and only works on absolutely positioned elements as NS4 cannot reflow a document (read: it is awful):

<layer name=&quot;netscrap&quot;>Original Text</layer>

<script>
document.netscrap.document.write(&quot;Some new text and <b>HTML</b>&quot;)
</script>

for a cross-browser solution in IE5+ and NS6/mozilla:

str = &quot;Some new text and <b>HTML</b>&quot;
document.getElementById(&quot;elementid&quot;).innerHTML = str


all of these techniques are coming from memory (eg I didn't test them!) so I'm not sure if the NS4 one will work. Speaking of which, you should only provide readable pages for NS4 - no dhtml! NS4 is holding back the web, and we as developers have to convince customers not to support it:

jared@eae.net -
 
I know from experience that the NS4 bodge will work. LAYERS and ILAYERS are the only things I have found that I can write into when ever I want, and the NS4 browser updates. In fact if you want confirmation of all the different ideas then YES they will all work in the browsers jaredn has done. Klae

You're only as good as your last answer!
 
Hi everybody !!

It was a good idea jaredn for this sample but it seems to still not work ...
 
Hi jaredn,

I found the problem !!
I solve it using document.open() and document.close() method like that :

document.open();
document.write(&quot;some text&quot;);
document.close();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top