textarea-textLength.html (774B)
1 <!DOCTYPE HTML> 2 <title>The textLengh IDL attribute</title> 3 <meta content="charset=utf-16"> 4 <link rel="author" title="tigercosmos" href="mailto:phy.tiger@gmail.com"> 5 <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-textarea-textlength"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <textarea id="textarea"></textarea> 9 <script> 10 var textarea = document.getElementById("textarea"); 11 12 test(function () { 13 textarea.value= "Hello, World!"; 14 assert_equals(textarea.textLength, 13); 15 16 textarea.value = "\u4f60\u597d\uff0c\u4e16\u754c\uff01"; //你好,世界! 17 assert_equals(textarea.textLength, 6); 18 }, "Textarea's 'testLength' should work for utf-16."); 19 </script>