document.open(“text/plain”) formatting ignored in webkit (safari, chrome)

后端 未结 2 413
别跟我提以往
别跟我提以往 2021-01-23 03:01

I am creating a page from JavaScript using document.open(\"text/plain\") and document.write(). The text to be rendered is multiple lines of tab separated text. In Chrome 13.0.7

2条回答
  •  被撕碎了的回忆
    2021-01-23 03:19

    You need to use the

     tag around your content in order to get it to render the way you want it to. The browser is still going to treat the document you're writing the code into as an HTML document. The 
     tag will tell the browser to render the content a pre-formatted text, which will honor all line breaks and white-space characters.

提交回复
热议问题