IE pre标签换行问题 var pre = document.createElement("pre");pre.innerHTML = id("content").value;//content是textarea标签的ID在FF,SAFARI,OPERA等浏览器都会保存换行,但在IE里就把换行替换成空格了,请问大虾有什么好的办法解决呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 IE7 和 FF3 下测试通过L@_@K<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> new document </title> <meta name="generator" content="editplus" /> <meta name="author" content="" /> <meta name="keywords" content="" /> <meta name="description" content="" /> </head> <body> <textarea id="content" rows="10" cols="40"></textarea> <input type="button" id="btnAppend" value="append pre" /> <script type="text/javascript"> <!--function $(sId) { return document.getElementById(sId);}$("content").value = "123\r 456";$("btnAppend").onclick = function() { var pre = document.createElement("pre"); if (window.navigator.appName == "Microsoft Internet Explorer") pre.innerText = $("content").value; else pre.innerHTML = $("content").value; document.body.appendChild(pre);}; //--> </script> </body></html> IE是够变态的<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><style type="text/css">pre{ border:1px solid red;}</style></head><body><textarea id="txt1" rows="10" cols="50">12345</textarea><pre>12345</pre><script type="text/javascript">function $(sId){ return document.getElementById(sId);}(function(){ var sHtml=$("txt1").value; var oPre=document.createElement("pre"); var oTxtNode=document.createTextNode(sHtml); sHtml=oTxtNode.nodeValue; oTxtNode.nodeValue=sHtml.replace(/\r\n/g,"\n"); oPre.appendChild(oTxtNode); document.body.appendChild(oPre);})();</script></body></html> easyUI 之 linkbutton 设置为不可用 ,还是可用 ~ 新手请教广告JQ Jquery 隐藏显示问题 关于日期比较的问题与return的问题。 关于菜单的 同时引用外部JS 和内部JS 这样写合理吗?? 一个js,onchange不能触发的问题 javascript转义字符好晕呢,很多层 有10个input文本框。要判断10个里面不为空的都不相等,有什么好办法 。谢谢了! 怎么在一定时间内让d2从d1的底部从下往上的盖住d1 一个有趣的剪刀石头布游戏(不会让你失望). 加载顺序与<body onload="xxx();">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
</head> <body>
<textarea id="content" rows="10" cols="40"></textarea>
<input type="button" id="btnAppend" value="append pre" />
<script type="text/javascript">
<!--
function $(sId) {
return document.getElementById(sId);
}$("content").value = "123\r 456";$("btnAppend").onclick = function() {
var pre = document.createElement("pre"); if (window.navigator.appName == "Microsoft Internet Explorer")
pre.innerText = $("content").value;
else
pre.innerHTML = $("content").value; document.body.appendChild(pre);
}; //-->
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
pre{
border:1px solid red;
}
</style>
</head>
<body>
<textarea id="txt1" rows="10" cols="50">1
2
3
4
5</textarea>
<pre>
1
2
3
4
5
</pre>
<script type="text/javascript">
function $(sId){
return document.getElementById(sId);
}(function(){
var sHtml=$("txt1").value;
var oPre=document.createElement("pre");
var oTxtNode=document.createTextNode(sHtml);
sHtml=oTxtNode.nodeValue;
oTxtNode.nodeValue=sHtml.replace(/\r\n/g,"\n");
oPre.appendChild(oTxtNode);
document.body.appendChild(oPre);
})();
</script>
</body>
</html>