Search code examples
javascripthtmlinternet-explorer-7internet-explorer-6

IE6/7 doesn't render html br tag


I am trying to separate each word with a newline in HTML/JS and IE6 and IE7 refuse to render the br tag, instead I get all in one line.

Here's the JS code: http://jsbin.com/atodur/edit#source

Is there any solution or workaround to this problem?

Thanks!


Solution

  • Problem is the code is not going into the else since word[i] is undefined.

    change

    if (word[i] != " ")
    

    to

    if (word.charAt(i) != " ")
    

    Basic Info:

    • word[i] is non standard way of access the characters of a string.
    • charAt() is the standard way

    String Character Access information