标签:
<script type="text/javascript">
function strReplace(str){
var t="",len=0;
t=str.replace(/\r\n\g,"\\n").replace(/\n\g,"");
document.form.output.value=t;
}
</script>
<body>
<form id="form" method="post" action="#">
<label>文本输入:</label><br>
<p>
<textarea name="input" cols="30" rows="3" id="input"></textarea>
</p>
<label>文本输出:</label>
<p>
<textarea name="output" cols="30" rows="1" id="output" readonly="readonly"></textarea><br>
</p>
<p>
<label>
<input type="button" name="Submit" value="强制阻止文本换行" onclick="strReplace(input.value)">
</p>
</form>
</body>
标签:
原文地址:http://blog.csdn.net/colorsunlight/article/details/44154809