By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,377 Members | 1,672 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,377 IT Pros & Developers. It's quick & easy.

Disappearing Child Nodes

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.