Solved

displaying non-ascii characters in a Javscript alert

Posted on 2011-02-11
3
490 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
Comment Utility
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
Comment Utility
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
Comment Utility
I added your doctype and charset reference, now it works! Thanks.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
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…
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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now