zedwood

width of character to detect asian language support

Aug 1st, 2012
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. http://stackoverflow.com/questions/604993/is-it-possible-to-detect-east-asian-language-support
  2. http://stackoverflow.com/questions/118241/calculate-text-width-with-javascript
  3. <html>
  4. <head>
  5. </head>
  6. <body>
  7. <script language="javascript" type="text/javascript">
  8. function length_of_char(str){
  9. var div = document.createElement('div');
  10. div.style.height='auto';
  11. div.style.width='auto';
  12. div.style.visibility='hidden';
  13. div.style.position='absolute';
  14. div.style.borderWidth='0px';
  15. div.appendChild( document.createTextNode(str) );
  16. document.documentElement.appendChild(div);
  17. return div.clientWidth;
  18. }
  19. var l1= length_of_char('\u30A2');
  20. var l2= length_of_char('\uFF71');
  21. console.log( l1 );
  22. console.log( l2 );
  23. </script>
  24. </body>
  25. </html>
Advertisement
Add Comment
Please, Sign In to add comment