KathyB said:
Hi, not sure this is the right group, but hoping someone may have
experienced this.
I'm passing html text as a parameter to a javascript. When it has an
apostrophe in it, of course it does parse correctly. BTW, using IE6
and msxml3/4.
Even if I manually escape the ' with \' or '' the browser just sees it
as \' or '' and not as an escaped apostrophe.
This is driving me nuts! Everyone just tells me to escape the
character.
Any clues most welcome!
You need to provide more detail. A link to a page or a small sample
of code that shows the problem would help.
Did you mean to say "of course it does NOT parse correctly" ?
How are you passing the HTML text?
Escape characters have no meaning in HTML.
Escape characters only have meaning in literal text.
They are ignored in text that is already in the value of a variable.
For example, the following code will produce a page reading:
Kathy\'s problem
Kathy\'s problem
Kathy's problem
<html>
<body>
<div id="alpha">Kathy\'s problem</div>
<script type="text/javascript">
document.write(document.getElementById("alpha").in nerHTML);
document.write("<br>Kathy\'s problem");
</script>
</body>
</html>
<html>
<body>
<div id="alpha">Kathy\'s problem</div>
<script type="text/javascript">
document.write(document.getElementById("alpha").in nerHTML);
document.write("<br>Kathy\'s problem");
</script>
</body>
</html>
Kathy\'s problem
Kathy\'s problem
Kathy's problem