Posted By

mooparmghor on 04/23/11


Tagged

javascript arabic numbering


Versions (?)

Display Arabic numbers in browsers supporting Unicode & JavaScript


 / Published in: JavaScript
 

URL: http://www.swalif.net/softs/swalif54/softs232281/

Replace English numbers with Arabic numbers in browsers supporting Unicode & JavaScript.

Credits to http://www.swalif.net/softs/swalif54/softs232281/

  1. var replaceDigits = function() {
  2. var map =
  3. [
  4. "&\#1632;","&\#1633;","&\#1634;","&\#1635;","&\#1636;",
  5. "&\#1637;","&\#1638;","&\#1639;","&\#1640;","&\#1641;"
  6. ]
  7.  
  8. document.body.innerHTML =
  9. document.body.innerHTML.replace(
  10. /\d(?=[^<>]*(<|$))/g,
  11. function($0) { return map[$0] }
  12. );
  13. }
  14.  
  15.  
  16. Example in how to use:
  17.  
  18. <!-- in the head tag of the page you want -->
  19. <head>
  20. <script type="text/javascript">
  21. window.onload = replaceDigits
  22. </script>
  23. </head>

Report this snippet  

You need to login to post a comment.