使用 jQuery 的.load()
方法我将文本加载到文本区域中。在 Chrome 和 FF 中运行良好。与往常一样,IE 必须有所不同,并且不会显示换行符。
我试过了white-space:pre-wrap
没有运气。
有任何想法吗?
My code:
$('#textarea').load('data.php');
The data.php只需查询 MySql 数据库并打印结果。
这大概是一个行结束问题。文本中是否有换行符\n
s or \r\n
是?如果他们只是\n
尝试规范化文本。您可以使用一些 JavaScript 来完成此操作:
function normalizeNewlines(text)
{
return text.replace(/(\r\n|\r|\n)/g, '\r\n');
}
This is a solution that's worked for me in the past when doing essentially the reverse: I needed to take text out of a <pre>
that could be pasted into !@#$ing
Notepad and show up with the line breaks intact.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)