Solved

displaying non-ascii characters in a Javscript alert

Posted on 2011-02-11
3
494 Views
Last Modified: 2012-05-11
This code:

alert ("Eine oder mehrere Ihrer Eingaben ist eine ungültige Zahl.");

ü is HTML for ü character (German). But when I put it in a Javascript alert, the browser actually displays ü instead of the character. If I put in ü then the browser displays garbage characters. How is the correct way to display a ü in an alert, if possible? Thank you!
0
Comment
Question by:bbdesign
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 34873682
HTML Entities like ü is not converted by alert (javascript).
What is the charset of your page ?

The following work for me (not HTML entities) :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">
alert("Eine oder mehrere Ihrer Eingaben ist eine ungültige Zahl.");
</script>
</head>
<body>
</body>
</html>

Open in new window

Clipboard05.jpg
0
 
LVL 82

Expert Comment

by:leakim971
ID: 34873693
The functions in the following page may help if needed (for example if you received HTML entities from a third party) : http://www.wikistuce.info/doku.php/javascript/htmlentites_et_html_entity_decode_comme_en_php#%5B1%5D
0
 

Author Comment

by:bbdesign
ID: 34873771
I added your doctype and charset reference, now it works! Thanks.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question