只处理了回车换行
<html>
<head>
<script language="javascript" type="text/javascript">
function ReplaceAll(strOrg,strFind,strReplace){
var index = 0;
while(strOrg.indexOf(strFind,index) != -1){
strOrg = strOrg.replace(strFind,strReplace);
index = strOrg.indexOf(strFind,index);
}
return strOrg
}
<head>
<script language="javascript" type="text/javascript">
function ReplaceAll(strOrg,strFind,strReplace){
var index = 0;
while(strOrg.indexOf(strFind,index) != -1){
strOrg = strOrg.replace(strFind,strReplace);
index = strOrg.indexOf(strFind,index);
}
return strOrg
}
function TextDisplay_Fun(form)
{
str = ReplaceAll(form.text1.value,"/n","<br/>");
TextDisplay.innerHTML=str;
}
{
str = ReplaceAll(form.text1.value,"/n","<br/>");
TextDisplay.innerHTML=str;
}
</script>
</head>
<body>
<div id="TextDisplay">
</div>
<form>
<textarea οnkeyup="TextDisplay_Fun(this.form);" style="WIDTH: 330px; HEIGHT: 361px" name="text1" rows="21" cols="40" type="text"></textarea>
</form>
</body>
</html>
</head>
<body>
<div id="TextDisplay">
</div>
<form>
<textarea οnkeyup="TextDisplay_Fun(this.form);" style="WIDTH: 330px; HEIGHT: 361px" name="text1" rows="21" cols="40" type="text"></textarea>
</form>
</body>
</html>