• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

display spanish accents in javascript alert

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am having trouble displaying an alert message in Spanish in my JSP. the local and everything is getting picked up currently but the spanish accents are not getting converted. Here is an example of what I am trying to do. I want to display the message "Email is required" in spanish using a window.alert() method.

so when i code it like


<script language="javascript" type="text/javascript" >
function showMsg()
{
window.alert('Direcci& #243;n de correo electr& #243;nico obligatorio.' + '\n');
}
</script>

<a href="javascript:alert('Direcci& #243;n de correo electr& #243;nico obligatorio.' + '\n');" > test1 </a>
<br>
<br>
<a href="javascript:showMsg();">test2</a>


the first link "test1" works fine. but the second link "test2" does not translate the '& #243;' to the corresponding accent but displays it as it is.

I added a space after the '&' symbol for the purpose of this post as the accent was getting translated.

Can anyone help me with this.Thanks in advance

[ June 30, 2008: Message edited by: ramana neelam ]
[ June 30, 2008: Message edited by: ramana neelam ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"raneelam",
Please check your private messages regarding an important administrative matter.
-Ben
 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems HTML entities are somehow not converted. You can use this code :



The key is the function html_entity_decode which actually seems to make html entities to be converted by browser rendering engine, rather than from the JavaScript engine.

Note : this snippet is not mine, I found it here : http://javascript.internet.com/snippets/convert-html-entities.html#
(just to not get credit for it)

[ July 01, 2008: Message edited by: Matteo Di Furia ]
[ July 01, 2008: Message edited by: Matteo Di Furia ]
 
kalpana gali
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Matteo, will try it this way.
reply
    Bookmark Topic Watch Topic
  • New Topic