 |
|
|  |
±ÛÀÚ¼ö¸¦ ¹ÙÀÌÆ®(Byte)·Î °è»êÇÏ¿© ¾Ë·ÁÁÖ´Â ¼Ò½º |
|
|
 |
12³â Àü |
ÀÔ·ÂµÈ ±ÛÀÚ°¡ ¸î Byte ÀÎÁö üũÇÏ´Â ¼Ò½º ÀÔ´Ï´Ù.
¸ðµÎ 3°¡Áö ¹æ¹ýÀÌ Àִµ¥ ¿øÇÏ´Â ¹æ¹ýÀ¸·Î ÀÌ¿ë ÇØ º¸¼¼¿ä
ù¹ø° ¹æ¹ý
<script language="javascript">
// ±ÛÀÚ¼ö Byte üũ
// value = ¹®ÀÚ¿
// id = ¹ÙÀÌÆ® ¼ýÀÚ Ç¥½Ã id ¸í
function TextByteChk(str,id)
{
var len = 0;
for (var inx = 0; inx < str.length; inx++) {
var oneChar = escape(str.charAt(inx));
if ( oneChar.length == 1 ) {
len ++;
} else if (oneChar.indexOf("%u") != -1) {
len += 2;
} else if (oneChar.indexOf("%") != -1) {
len += oneChar.length/3;
}
}
document.getElementById(id).value = len;
}
</script>
<textarea onblur="TextByteChk(this.value,'bytewrite');" onKeyUP="TextByteChk(this.value,'bytewrite');"></textarea>
<input type="text" id="bytewrite" value="" readonly>
µÎ¹ø° ¹æ¹ý
<script language='javascript'>
String.prototype.bytes = function() {
var str = this;
var l = 0;
for (var i=0; i<str.length; i++) l += (str.charCodeAt(i) > 128) ? 2 : 1;
return l;
}
function cal_pre()
{
var size_check = document.form.comment.value;
document.form.size.value = size_check.bytes();
}
function check()
{
var size_check = document.form.comment.value;
if (size_check.bytes() > 200)
{
alert("ÀÛ¼ºÇϽŠ±ÛÀº "+size_check.bytes()+" Byte À̸ç 200 Byte ÀÌÇÏ·Î ÇØÁÖ¼¼¿ä");
}
else
{
alert("ÀÛ¼ºÇϽŠ±ÛÀº "+size_check.bytes()+" Byte ÀÔ´Ï´Ù.");
}
}
</script>
<form name='form'>
<input type='text' name='comment' value='' onKeyUP="javascript:cal_pre();">
<input type='text' name='size' size='3' value='' readonly>
<input type='button' value='È®ÀÎ' onclick='check()'>
</form>
|
|
̵̧ : 607 |
̵̧
¸ñ·Ï
|
|
|  |
|