»
Tiếng AnhTiếng PhápTiếng Việt

In - Nhận biết kí tự xuống dòng - JavaScriptBank.com

Phiên bản đầy đủ: jsB@nk » Ứng dụng » Nhận biết kí tự xuống dòng
URL: https://www.javascriptbank.com/remove-returns-script.html

Nhận biết kí tự xuống dòng © JavaScriptBank.comHiệu ứng sẽ kiểm tra chuỗi do người dùng nhập vào và sẽ hiển thị nơi xuống dòng của mỗi câu trong chuỗi.

Phiên bản đầy đủ: jsB@nk » Ứng dụng » Nhận biết kí tự xuống dòng
URL: https://www.javascriptbank.com/remove-returns-script.html



JavaScript
<SCRIPT LANGUAGE="JavaScript">// Ascii King (chicorama@usa.net) | http://www.geocities.com/enchantedforest/2120<!-- Beginfunction ConvertBR(input) {// Converts carriage returns // to <BR> for display in HTMLvar output = "";for (var i = 0; i < input.length; i++) {if ((input.charCodeAt(i) == 13) && (input.charCodeAt(i + 1) == 10)) {i++;output += "<BR>";} else {output += input.charAt(i);   }}return output;}//  End --></script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<form><textarea name=message rows=8 cols=50>You may type a message hereMake sure to press the [Enter] key a few times.That way you will be able to see the conversion function in action.</textarea><p><input type=button value="Convert Returns" onClick="this.form.output.value = ConvertBR(this.form.message.value);"><p>Output:  <input type=text name=output size=50><p></form><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->