472,108 Members | 1,850 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,108 software developers and data experts.

mozilla, innerHTML, and then?

I am doing some maintenance on a js tree control that was done with
proprietary IE code.

When I click on a node it calls a function which has code similar to
that below to expand the tree. "el" refers to the div that I clicked
on.

var workHtml = el.innerHTML;

for (i = 0; i < idx; i++)
{
strHtml = '<div><span onclick=f_Click("'+ idx +
'")></span></div>';

workHtml = strHtml + workHtml;

}
el.innerHTML = workHtml;
Now, this works, both in IE and FireFox, but in FireFox I get the
"Waiting..."
message in the status bar at the bottom of the frame.

Is there something more I should add? Or should I have used another
approach rather than innerHTML? (I'm replacing the proprietary
insertAdjacentHTML).

Thanks

Jul 23 '05 #1
1 1264


jh*****@yahoo.com wrote:
I am doing some maintenance on a js tree control that was done with
proprietary IE code.

When I click on a node it calls a function which has code similar to
that below to expand the tree. "el" refers to the div that I clicked
on.

var workHtml = el.innerHTML;

for (i = 0; i < idx; i++)
{
strHtml = '<div><span onclick=f_Click("'+ idx +
'")></span></div>';

workHtml = strHtml + workHtml;

}
el.innerHTML = workHtml;
Now, this works, both in IE and FireFox, but in FireFox I get the
"Waiting..."
message in the status bar at the bottom of the frame.

Is there something more I should add?
I am guessing but a message in the status bar is not likely to be caused
by some innerHTML change, perhaps you are calling that code from a link e.g.
<a href="javascript: functionName()">
or
<a href="#"
onclick="functionName();">
and the problem goes away with
<a href="#"
onclick="functionName(); return false;">
Or should I have used another
approach rather than innerHTML?


If you want to add elements to the el element then you can use the W3C
DOM e.g.
var div, span;
if (document.createElement && (div = document.createElement('div'))) {
span = document.createElement('span');
span.onclick = function (evt) { f_Click(idx); };
// maybe you need
// span.onclick = new Function ("evt", "f_Click('" + idx + "');");
// instead, I am not sure what idx is in your snippet
span.appendChild(document.createTextNode('span content'));
div.appendChild(span);
el.appendChild(div);
}

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Mitch | last post: by
10 posts views Thread by tony kulik | last post: by
1 post views Thread by Ted Weatherly | last post: by
6 posts views Thread by Red_Indian | last post: by
8 posts views Thread by Clément | last post: by
8 posts views Thread by bennett.matthew | last post: by
2 posts views Thread by Jonny B | last post: by
reply views Thread by leo001 | last post: by

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.