<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript">
function run()
{
  str=document.all.textfield.value;
str=str.replace(/\r\n/g,"_net_lover_");
alert(str)
document.all.textfield2.value=str.replace(/_net_lover_/g,"\r\n");
}
</script>
</head><body bgcolor="#FFFFFF" text="#000000">
<textarea name="textfield"></textarea>
<textarea name="textfield2"></textarea>
<input type="submit" name="Submit" value="Submit" onClick=run()>
</body>
</html>

解决方案 »

  1.   

    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <script language="JavaScript">
    function run()
    {
      str=document.all.textfield.value;
    str=str.replace(/\r\n/g,"$$");
    alert(str);
    document.all.textfield2.value=str.replace(/\$/g,"\r\n");
    }
    </script>
    </head><body bgcolor="#FFFFFF" text="#000000">
    <textarea name="textfield"></textarea>
    <textarea name="textfield2"></textarea>
    <input type="submit" name="Submit" value="Submit" onClick=run()>
    </body>
    </html>