Solved

displaying non-ascii characters in a Javscript alert

Posted on 2011-02-11
3
497 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…

726 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