jalarie on Jul 15, 2010 at 1:12:33 PM (# 2) This message has been edited.Use the JavaScript "Data=window.document.body.innerHTML;" to read the data.
The Greek codes run from 913 through 937 for the upper-case alpha through omega and from 945 through 969 for the lower-case. Put an and sign (&) and pound sign (#) ahead of the code number and a semicolon (;) after it. frumbert on Jul 15, 2010 at 4:12:56 PM (# 3) This message has been edited.actually this does not work. Consider the following example. When you press the button you get an alert that shows the original string that was set as the value in the p, and what you get when it reads the same value back using innerHTML. They are not the same thing. <html> <head> <script type="text/javascript"> function doIt() { var s = "The quick brown ω is © copyright 2010"; var el1 = document.getElementById("my_p"); var el2 = document.getElementById("my_other_p"); el1.innerHTML = s; el2.appendChild(document.createTextNode(s)); var read1 = el1.innerHTML; var read2 = el2.innerHTML;
alert("Original value:\n"+s+"\nInner HTML1:\n"+read1+"\nInner HTML2:\n"+read2); } </script> </head> <body> <h1>First value</h1> <p id="my_p"></p> <h1>Second value</h1> <p id="my_other_p"></p> <input type="button" value="go" onclick="doIt()" /> </body> </html> Terry Young on Jul 21, 2010 at 10:18:39 AM (# 4) This message has been edited.The line with createTextNode is flawed.
createTextNode creates text, not HTML
Your "s" variable is essentially an HTML string, not a text string.
Here:
document.createTextNode("The quick brown " + String.fromCharCode(969) + " is " + String.fromCharCode(169) + " copyright 2010")
Still thinking about the original question though... Terry Young on Jul 21, 2010 at 10:43:01 AM (# 5) This message has been edited.Stumbled upon this:
http://www.dave-smith.info/character-entity-reference-converter-using-javascript.html
Copy this rendered "The quick brown ω is © copyright 2010" into the textarea and click "Convert".
Looks like an exhaustive approach.
Not yet sure if this is the only solution, but I believe it is. MHenke on Jul 23, 2010 at 2:51:13 AM (# 6) This message has been edited.It's not that I've to say something substantial WRT the original question. But, as always, I don't care a pap. I just want to say how gratifying it is to see an actual discussion on SE. As much as such renowned members are involved (e.g. mhenke). ;)
|