Using JS "WRITE" type functionality without erasing the original page.

E

Eric

Is it possible? I'm trying to add to the current page -- but add at a
specific point. Can add HTML tags from javascript midway through the page
(at a place I specify) without erasing the existing page?

Thanks,
Eric
 
E

Eric

Right -- but DOM2 isn't universally supported (not that javascript is -- but
I wanted to do a little bit better than IE5). Is this my only option?

Thanks,
Eric
 
L

Lasse Reichstein Nielsen

Please keep a little of the post you are answering so we can see wha
you refer to.
Right -- but DOM2 isn't universally supported (not that javascript is -- but
I wanted to do a little bit better than IE5).

What does IE5 do, and what would be better?
Is this my only option?

(the one in the FAQ?)

It is a *good* option. It works in IE4+, NS6+ and Opera 7.

The code is not very pretty, though. Try this instead:
---
function writeHTML(id,S) {
var elem = (document.getElementById ? document.getElementById(id) :
(document.all ? document.all[id] : undefined));
if (!elem) { return false; }
elem.innerHTML = S;
return true;
}
---
It works in any browser that understands .innerHTML. Adding support
for NS4 requires some extra work, but is possible if the element
to write into is absolutely positioned.

I don't know what other browsers are out there that allows changing
the contents of the page dynamically.

/L
 
C

Chris Wright

Right -- but DOM2 isn't universally supported (not that javascript is -- but
I wanted to do a little bit better than IE5). Is this my only option?
If you don't want to use innerHTML etc. then you could include a
JavaScript document.write() in the HTML document at the appropritate
point.

If you need to alter is after the HTML page hase rendered then reload
the page with the variables driving the document.write() primed to
include the new data.

This might require using data saved in another frame, or cookie etc.

HTH
 
E

Eric

I never even thought of placing the document.write statement within the
document as opposed to the beginning or end of the document.

Thanks!
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top