mozilla, innerHTML, and then?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jhcorey@yahoo.com

    #1

    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
    insertAdjacentH TML).

    Thanks

  • Martin Honnen

    #2
    Re: mozilla, innerHTML, and then?



    jhcorey@yahoo.c om wrote:
    [color=blue]
    > 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?[/color]

    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="javascrip t: functionName()" >
    or
    <a href="#"
    onclick="functi onName();">
    and the problem goes away with
    <a href="#"
    onclick="functi onName(); return false;">
    [color=blue]
    > Or should I have used another
    > approach rather than innerHTML?[/color]

    If you want to add elements to the el element then you can use the W3C
    DOM e.g.
    var div, span;
    if (document.creat eElement && (div = document.create Element('div')) ) {
    span = document.create Element('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.appendChil d(document.crea teTextNode('spa n content'));
    div.appendChild (span);
    el.appendChild( div);
    }



    --

    Martin Honnen
    http://JavaScript.FAQTs.com/

    Comment

    Working...