How to display arabic in Javascript?
I am usi开发者_如何学Cng utf-8 in my jsp page. I have set the page pageEncoding="UTF-8" contentType="text/html;"
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
But when i try to alert a UTF-8 value then its coming as same utf-8 characters.
But is the DATA on the page UTF-8 too? If you set the page to UTF-8 but load data which is for example Windows 1256, you will not see Arabic at all
If your issue is alert('Something Arabic here') you may want to use entities
Here is a good explanation http://www.w3.org/International/tutorials/bidi-xhtml/
Here is a few methods (perhaps not THE methods):
alert(document.getElementBzId('hiddenDiv').innerHTML)
where you have
<div id="hiddenDiv" style="display:none">استمارة طلب توظيف</div>
the other one is creating it dynamically
<script>
var alertString = "استمارةطلب توظيف"
var d = document.createElement('div');
d.innerHTML=alertString;
alert(d.innerHTML)
</script>
If the page is properly encoded UTF-8 then my first guess is that the HTTP headers are indicating something other than UTF-8. HTTP headers override <meta http-equiv
, read HTML 4.01 here.
Check in a browser the exact HTTP response headers. If there is an inappropriate Content-Type
header, change it. If there is none, add one.
精彩评论