Web Analytics Made Easy -
StatCounter Need help displaying html entity from javascript context.filltext - CodingForum

Announcement

Collapse
No announcement yet.

Need help displaying html entity from javascript context.filltext

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need help displaying html entity from javascript context.filltext

    I am creating a picture using the drawing canvas. All has been displaying well until I tried to display the Greek theta (&theta. Using θ or the hex code equivalent in the call:
    Code:
    context.beginPath(); context.fillText(θ, 206, 177);
    just gives an error message. (Safari 9.1.3) Putting quotes around the entity results in displaying the code and not the entity. Similarly, putting the code in a variable (with or without quotes) and putting the variable in the fillText call also displays just the entity code.

    I am not an experienced programmer, so I am hoping a simple solution exists.

    Thanks in advance for input, advice, solutions.

    John

  • #2
    You are using JavaScript and not HTML so you need to use the JavaScript entity code and not the HTML one.

    I think what you are after is \u0398
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

    Comment


    • #3
      Thanks felgall!!!
      Code:
      context.fillText('\u0398', 206, 177);
      worked like a champ. Finish the picture and then code the math.

      Have a great Spring.

      John

      Comment

      Working...
      X