SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    London
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript and HTML entities

    Hi All

    I need some help with Javascript and HTML entities. I am writing some code and I need to use quite a few HTML entities on alert boxes (messages in different languages)

    Unfortunately Javascript displays the entities and not the equivalent caracther.

    Can anyone advice me on how to tackle this problem please?

    Many thanks
    giove

  2. #2
    SitePoint Enthusiast
    Join Date
    Jun 2006
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The string you try to alert, does it look like:

    1) Hello W°rld

    or

    2) Hello Wørld

    ?
    Soren Beck Jensen

    http://www.automaticbacklinks.com - Free link exchange network
    http://www.notwebdesign.com - Joomla web design in Spain

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    London
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by CT Internet
    The string you try to alert, does it look like:

    1) Hello W°rld

    or

    2) Hello Wørld

    ?

    Hi CT Internet

    It comes out like the 2nd one and I would like to display like n1

    cheers
    giove

  4. #4
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use unicode escapes in javascript, html escapes in html.

    for instance: alert('\u0026') instead of alert('&')

    http://www.unicode.org/
    Last edited by mrhoo; Nov 22, 2006 at 16:34.

  5. #5
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    London
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mrhoo
    Use unicode escapes in javascript, html escapes in html.

    for instance: alert('\u0026') instead of alert('&')

    http://www.unicode.org/

    thanks mrhoo, - that works fine!
    only problem I will have to spend the next few days finding all the unicode characters i need

    giove

  6. #6
    SitePoint Enthusiast
    Join Date
    Jun 2006
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As an alternative you can pop up a html window or make a div visible or something like that so you keep everything HTML instead of using the JavaScript alert() function.
    Soren Beck Jensen

    http://www.automaticbacklinks.com - Free link exchange network
    http://www.notwebdesign.com - Joomla web design in Spain

  7. #7
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    London
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by CT Internet
    As an alternative you can pop up a html window or make a div visible or something like that so you keep everything HTML instead of using the JavaScript alert() function.
    thanks CT Internet, I have now started unicoding my character and building a "find and replace" database for future use ;-)

    giove

  8. #8
    Caveat surfer Buddy Bradley's Avatar
    Join Date
    May 2003
    Location
    Cambridge, UK
    Posts
    2,366
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sounds like you need this page.

  9. #9
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    London
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Buddy Bradley
    Sounds like you need this page.

    thanks Buddy Bradley, does anyone know the oct character for the EURO sign?

    I have tried a few to no avail.

    cheers
    giove

  10. #10
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    euro='\u20AC'

  11. #11
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    London
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mrhoo
    euro='\u20AC'

    cheers mrhoo, that works fine ! ;-)

    giove


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •