Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Removing nodes from DOM in AvantGo Javascript

2 posts in General Discussion Last posting was on 2004-08-13 19:15:50.0Z
Nicolas Damour Posted on 2004-08-13 17:19:46.0Z
From: "Nicolas Damour" <nicolas.damour@sybase.com>
Newsgroups: ianywhere.public.mbusinessanywhere.general
Subject: Removing nodes from DOM in AvantGo Javascript
Lines: 82
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: chello080108002014.34.11.vie.surfer.at
X-Original-NNTP-Posting-Host: chello080108002014.34.11.vie.surfer.at
Message-ID: <411cf832@forums-1-dub>
Date: 13 Aug 2004 10:19:46 -0700
X-Trace: forums-1-dub 1092417586 80.108.2.14 (13 Aug 2004 10:19:46 -0700)
X-Original-Trace: 13 Aug 2004 10:19:46 -0700, chello080108002014.34.11.vie.surfer.at
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.mbusinessanywhere.general:139
Article PK: 17594

Hi.
I'm trying to dynamically remove some objects using AvantGo Javascript in a
web document. However, it seems that the removeChild() method of the Node
interface (developer's user guide on page 342) does not work as expected :
the node is well removed from the DOM tree structure, but remains accessible
through document.getElementById(), which is annoying for two reasons :
1. It occupies memory space although it is not needed anymore;
2. I would like to create and use another node having the same name, and I
get bothered because the old node is still there with the same name.
I'm using the M-Business Client for PalmOS, version 5.5 build 95, and
herebelow follows my sample code. The problem is outlined with my element
named "testNode1", which clearly remains after having been "deleted". I can
partially solve the aforementioned issue #2 by explicitly setting the
testNode2.id to another value, but this is not really satisfying when I
remove a big tree structure from the DOM tree, and it doesn't solve issue
#1.
Am I doing this wrong, or is there no way to really get rid of the object.
Could the DOM NamedNodeMap interface be the solution, if only it was
implemented by the AvantGo Javascript engine?
Thanks for your help,
Nicolas.
<html>

<head>

<script language="Javascript">

function removeTestNodes() {

// Removing testNode1 from DOM

var elt1 = document.getElementById("testNode1");

alert("elt1 = " + elt1);

document.getElementById("testJavaScript").removeChild(document.getElementByI
d("testNode1"));

var elt1 = document.getElementById("testNode1");

alert("elt1 = " + elt1);

// Removing testNode2 from DOM

var elt2 = document.getElementById("testNode2");

alert("elt2 = " + elt2);

var node =
document.getElementById("testJavaScript").removeChild(document.getElementByI
d("testNode2"));

node.id = "garbage";

var elt2 = document.getElementById("testNode2");

alert("elt2 = " + elt2);

}

</script>

</head>

<body>

<div id="testJavaScript">

<a nohref onclick="removeTestNodes()">Remove text nodes</a>

<p id="testNode1">This is text 1</p>

<p id="testNode2">This is text 2</p>

</div>

</body>

</html>


Yadong Liu Posted on 2004-08-13 19:15:50.0Z
Sender: 566b.411c0d3b.1804289383@sybase.com
From: Yadong Liu
Newsgroups: ianywhere.public.mbusinessanywhere.general
Subject: Re: Removing nodes from DOM in AvantGo Javascript
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <411d1366.64bd.1681692777@sybase.com>
References: <411cf832@forums-1-dub>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 13 Aug 2004 12:15:50 -0700
X-Trace: forums-1-dub 1092424550 10.22.241.41 (13 Aug 2004 12:15:50 -0700)
X-Original-Trace: 13 Aug 2004 12:15:50 -0700, 10.22.241.41
Lines: 95
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.mbusinessanywhere.general:140
Article PK: 8734

Without knowing the specifics of what you are trying to do,
generally speaking it is better, in terms of performance on
PDA, to modify a node value than to remove and replace it.
For example in your case, you would want to use
document.getElementById("testNode2").nodeValue = "new
paragraph text";

Hope this helps.

> Hi.
> I'm trying to dynamically remove some objects using
> AvantGo Javascript in a web document. However, it seems
> that the removeChild() method of the Node interface
> (developer's user guide on page 342) does not work as
> expected : the node is well removed from the DOM tree
> structure, but remains accessible through
> document.getElementById(), which is annoying for two
> reasons : 1. It occupies memory space although it is not
> needed anymore; 2. I would like to create and use another
> node having the same name, and I get bothered because the
> old node is still there with the same name. I'm using the
> M-Business Client for PalmOS, version 5.5 build 95, and
> herebelow follows my sample code. The problem is outlined
> with my element named "testNode1", which clearly remains
> after having been "deleted". I can partially solve the
> aforementioned issue #2 by explicitly setting the
> testNode2.id to another value, but this is not really
> satisfying when I remove a big tree structure from the DOM
> tree, and it doesn't solve issue #1.
> Am I doing this wrong, or is there no way to really get
> rid of the object. Could the DOM NamedNodeMap interface be
> the solution, if only it was implemented by the AvantGo
> Javascript engine? Thanks for your help,
> Nicolas.
>
>
>
>
>
>
> function removeTestNodes() {
>
> // Removing testNode1 from DOM
>
> var elt1 = document.getElementById("testNode1");
>
> alert("elt1 = " + elt1);
>
> document.getElementById("testJavaScript").removeChild(docu
> ment.getElementByI d("testNode1"));
>
> var elt1 = document.getElementById("testNode1");
>
> alert("elt1 = " + elt1);
>
> // Removing testNode2 from DOM
>
> var elt2 = document.getElementById("testNode2");
>
> alert("elt2 = " + elt2);
>
> var node =
> document.getElementById("testJavaScript").removeChild(docu
> ment.getElementByI d("testNode2"));
>
> node.id = "garbage";
>
> var elt2 = document.getElementById("testNode2");
>
> alert("elt2 = " + elt2);
>
> }
>
>
>
>
>
>
>
>
>
> Remove text nodes
>
> This is text 1
>
> This is text 2
>
>
>
>
>
>
>
>
>