我的代码:
<div id="box">
<p>
123
</p>
<p>
abc
</p>
</div>
<script>
var html = document.getElementById("box").innerHTML;
alert(html) //you can the different HTMLString between IE6/7/8 and IE9/FF
for (var i = 0, len = html.length; i < len; i++) {
var word = html.charAt(i)
if(i == 0){
alert(word=="\n") // IE6/7/8: false . IE9/FF:true
}
if(i == 11){
alert(word=="\n") //Look at here in IE6/7/8, why is false ??????
}
}
</script>
当 (i==11) 时,IE6/7/8 中此处的字符正在换行,但为什么显示为 false?
怎么写我可以知道html的代码在IE6/7/8中换了一个新行??