Arabic characters doesn't show properly in JavaScript -


when add arabic characters in javascript, not showed properly. guess ascii problem. suggestions?

javascript

document.getelementbyid('div-msg').innertext = "اسم المستخدم لا يمكن أن تترك فارغة"; 

html

<html> <head>  </head> <body>     <div id="div-msg" style="width:100%; height:200px; background:yellow">      </div>     <script type="text/javascript">         document.getelementbyid('div-msg').innertext = "اسم المستخدم لا يمكن أن تترك فارغة";     </script> </body>  </html> 

i have met issue when tried write turkish characters. solution simple.

  • first, move javascript code external script file.
  • second, add script html charset attribute below

    <script src="external_script.js" charset="utf-8" type="text/javascript"></script> 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -