473,508 Members | 2,079 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Disappearing Child Nodes

I am working on dynamic page changes using the DOM. However when I run the
following code, the new child nodes don't last. They flash for a second on
the page and then disappear. I would understand if I was removing nodes,
but I am not. Any clue guys?

<script type="text/javascript">
function gettitle(nameoftitle){
var x = document.getElementById('htitle');
var y = document.createTextNode(nameoftitle.firstChild.nod eValue);
if(!x.firstChild){
x.appendChild(y);
}else{
x.firstChild.nodeValue = nameoftitle.firstChild.nodeValue;
}
}
</script>
<body>
<h1 id="htitle"></h1>
<a href="" onClick="gettitle(this)">index</a> <a href=""
onClick="gettitle(this)">testing</a>
</body>
Jul 23 '05 #1
2 1209
You need to return false from the onclick handlers or the browser will
still follow the link.

Tim

"cah2240" <ca*****@mail.usf.edu> wrote in message
news:pa****************************@mail.usf.edu.. .
I am working on dynamic page changes using the DOM. However when I
run the
following code, the new child nodes don't last. They flash for a
second on
the page and then disappear. I would understand if I was removing
nodes,
but I am not. Any clue guys?

<script type="text/javascript">
function gettitle(nameoftitle){
var x = document.getElementById('htitle');
var y = document.createTextNode(nameoftitle.firstChild.nod eValue);
if(!x.firstChild){
x.appendChild(y);
}else{
x.firstChild.nodeValue = nameoftitle.firstChild.nodeValue;
}
}
</script>
<body>
<h1 id="htitle"></h1>
<a href="" onClick="gettitle(this)">index</a> <a href=""
onClick="gettitle(this)">testing</a>
</body>

Jul 23 '05 #2
On Sat, 25 Dec 2004 00:12:17 +0000, Tim Williams wrote:
You need to return false from the onclick handlers or the browser will
still follow the link.

Thank you for the hint. I found that it was the href="" was the problem. I
will however keep that in mind during further development.

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
4135
by: kaeli | last post by:
Can anyone explain this to me? It's driving me insane. Save this and run it in IE or Opera and then in Mozilla or Netscape 6+. In IE/Opera, I get the expected 4 alerts. In Mozilla/Netscape, I...
1
3064
by: Hazz | last post by:
I have 5 tables in SQL Server. Each with the following design and a sample chain of the relationships from the root (WRL - World) UUS is the 'Code' of the first table and it is the 'Parent' value...
12
20502
by: Dino L. | last post by:
I am putting data from DataTable to treeView foreach( DataRow aRow in aTable.Rows) { TreeNode tnode = new TreeNode(aRow.ToString() + aRow.ToString() + " " + aRow.ToString());...
7
3747
by: amruta | last post by:
the code below dows not let me get the parent child view... all the nodes are show in one line only... also i need them to be collasped ... Thanks ..
2
21987
by: Jack | last post by:
Hello, I am trying use a TreeView with checkboxes. I would like to check more than one node and allow all child nodes of selected nodes to be checked or unchecked with the parent is checked. ...
1
2314
by: Daniel Rucareanu | last post by:
Hello, Does anybody knows how can you delete, in just one step, not using a loop, a subset of the child nodes of a given DOM parent node? The subset will be continous, so for example, if the...
2
21800
by: GreggaR0und | last post by:
Hello; I'm trying to iterate through the sub nodes of a child node, but I'm getting a compile error on the nested For...Next expression saying it is invalid. Using the below code, the HasChild()...
1
2727
by: karthee | last post by:
I am creating a custom treeview with multiple selection, if i select multiple nodes and right click, the selection is disappearing, i tried with somany things like on mouse click my code is...
0
3276
by: divya1949 | last post by:
Create a windows c# application which will Read a xml file and populate nodes in the treeview. 1 On selection of treenode display the child nodes of that node in listview control 2. ...
0
7328
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7388
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7499
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5055
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4709
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3186
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1561
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
767
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
422
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.