I have a link that I dynamically create which looks something like the following:
<a onclick='Edit('value from a text column here')' href='javascript:void(null);'>Edit</a>
with the Edit function then taking the passed in value and putting it into a Yahoo Rich Text Editor. This works well except for when there is a single quote in the text being passed. The obvious problem being that the link then looks something like:
<a onclick='Edit('I'm a jelly donut')' href='javascript:void(null);'>Edit</a>
Any suggestions on what I can do? I’d rather not stray too far from the structure I am currently using because it is something of a standard (and maybe the standard sucks, but that’s another question altogether).
Note: I am using ASP as my server side language.
Convert quote charaters to their HTML equivalents,
"etc. before you insert them into the HTML. There’s a long list of HTML/XML character codes on wikipedia.There may well be a function to do this for you, depending on how you’re dynamically generating the code: PHP has htmlspecialchars, and though I’m not familiar with ASP etc, I’m sure there are similar routines.