How to count new lines in Internet Explorer?

Posted by Impirator on Stack Overflow See other posts from Stack Overflow or by Impirator
Published on 2010-05-10T23:44:12Z Indexed on 2010/05/11 16:54 UTC
Read the original article Hit count: 228

Filed under:
|
|

Hey, all. I'm doing my own syntax highlighter for Javascript and CSS, and I've run into an issue with Internet Explorer (big surprise). I grab all the contents of a code.block tag (example below) using innerHTML, and .split("\n") that result to get each line by itself. This works wonderfully except in IE.

I have tried using innerText and .split("\r\n") also without success. Can anyone recommend a solution? If it makes a difference, my code.block tags are styled to be white-space:pre-wrap.

<code class="block css">div#randomBarsDemo {
    width:175px;
    height:200px;
}

div#randomBarsDemo div {
    background-color:#111;
    width:100%;
}</code>

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about internet-explorer