Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Using JS "WRITE" type functionality without erasing the original page.

Reply
Thread Tools

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

 
 
Eric
Guest
Posts: n/a
 
      07-21-2003
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


 
Reply With Quote
 
 
 
 
Eric
Guest
Posts: n/a
 
      07-21-2003
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


 
Reply With Quote
 
 
 
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      07-21-2003
"Eric" <> writes:

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
--
Lasse Reichstein Nielsen -
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
 
Reply With Quote
 
Chris Wright
Guest
Posts: n/a
 
      07-21-2003
On Mon, 21 Jul 2003 00:02:17 -0700, "Eric" <> wrote:

>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
 
Reply With Quote
 
Eric
Guest
Posts: n/a
 
      07-21-2003
I never even thought of placing the document.write statement within the
document as opposed to the beginning or end of the document.

Thanks!


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
open for writing without immediately erasing mike Perl Misc 4 03-03-2009 08:21 AM
Nodes.Clear() is also erasing my session variables Alex D. ASP .Net 4 11-23-2005 03:41 AM
Re: Help Erasing Files on CDRW Disk mousely Computer Support 7 10-01-2004 04:39 AM
reinstall XP,without erasing data? Joe A+ Certification 1 02-04-2004 07:57 PM
Re: Error Download file from TFTP after erasing Flash ( Cisco 2610) Rainer Temme Cisco 2 07-09-2003 02:17 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57