Euro sign or other entity in Javascript alert/messagebox

爱⌒轻易说出口 提交于 2019-12-31 17:51:23

问题


Does anybody know how i can show a euro or other html entity in javascript alert windows?


回答1:


alert('\u20AC');

HTML Entity Character Lookup




回答2:


<script>alert("\u20ac");</script>

(20AC being the Unicode character for the euro sign.)




回答3:


An alert box can show any characters that are in the codepage for the currently logged on session. So for example if the machine is using the 1252 codepage you can display the eurosign.

Its not clear what your trouble is, you javascript string should not have the characters encoded as entities anyway?

Edit:

If you specify UTF-8 in the HTML or as the Response.CharSet but you haven't actually saved the ASP file in UTF-8 format you will have problems with characters outside of ASCII.

ASP assumes static parts of an ASP file are in the required codepage already and sends it verbatim byte for byte, no encoding will happen.




回答4:


for example, U+1234 is used like this: alert('\u1234').

For full list, you can see All Entity list:
1) http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
2) http://www.utf8-chartable.de/
3) http://rishida.net/tools/conversion/ (CONVERTER)



来源:https://stackoverflow.com/questions/661524/euro-sign-or-other-entity-in-javascript-alert-messagebox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!