Whitespace in Firefox

I have been busy doing stuff with the DOM at work. One thing that continually bugs me is that Firefox seems to find a lot of whitespace and called them textnodes. Obviously when you use firstChild, lastChild, nextSibling or previousSibling and you think that what you are getting from your script should be a div or something other than a textnode this can cause some problems.

Internet Explorer seems to have no problem negotiating the whitespace which annoys me as I really like using Firefox and this is one of the few bad things I have come across concerning this browser.

Whitespace in the DOM explains why this happens and provides a handy little script that helps overcome the problem. It probably explains the problem better than I have as well!

Comments

2 Responses to “Whitespace in Firefox”

  1. nuthell

    great.today,when i was coding with firefox,i met the problem.the code is here.
    /*—————–*/
    function mycall(element){
    element=$(element);
    alert(element.className);
    element.nextSibling.style.display=”none”;
    }
    /*———–*/
    the key word-”nextSibling” works well with IE,but died with Firefox.

  2. matthew

    Yep - that looks like the problem - sometimes you can go into the html and remove the spaces and that sorts it but I think the script I mention above takes out the guess work.

Leave a Reply