Display Arabic numbers in browsers supporting Unicode & JavaScript


/ Published in: JavaScript
Save to your folder(s)

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

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


Copy this code and paste it in your HTML
  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>

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.