Javascript Removing Whitespace When It Shouldn't?

前端 未结 10 2045
谎友^
谎友^ 2020-12-11 05:29

I have a HTML file that has code similar to the following.


&         
10条回答
  •  轮回少年
    2020-12-11 05:42

    This is a bit hacky, but it works on my IE.

     
    
    
        
    
    
    
    a b

    Some notes:

    • You must have a doctype.
    • You cannot query the DOM element before window.onload has fired
    • You should use element.nodeValue instead of innerHTML et al to avoid bugs when the text contains things like < > & "
    • You cannot reset whiteSpace once IE finishes rendering the page due to what I assume is an ugly bug

提交回复
热议问题
Hello World