<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Character count test</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="generator" content="Geany 0.18.1.1" />
<style type="text/css">
#report {
white-space: -moz-pre-wrap; /* Mozilla, supported since 1999 */
white-space: -pre-wrap; /* Opera 4 - 6 */
white-space: -o-pre-wrap; /* Opera 7 */
white-space: pre-wrap; /* CSS3 - Text module (Candidate Recommendation) http://www.w3.org/TR/css3-text/#white-space */
word-wrap: break-word; /* IE 5.5+ */
}
</style>
<script type="text/javascript">
function count_symbols() {
var val = document.getElementById('counter').value,
len = val.replace(/\r\n/g, '\n').length;
document.getElementById('report').
appendChild(document.createTextNode(len + '\n'));
}
</script>
</head>
<body>
<p><textarea id="counter" rows="5" cols="20">это
просто
тест</textarea></p>
<p><button onclick="count_symbols()">Count</button></p>
<p id="report"></p>
</body>
</html>
Какой идиот придумал виндовые переводы строк...