<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>
时间: 2024-10-15 10:21:37