On 13/08/2006 16:19, Dustin wrote:
[snip]
var myHTML = "<TR onMouseOver='return overlib(\"<A
HREF=\'javascript:void(0)\'
onClick=\'javascript:getXMLFeed(\"price\")\'>Price </A>\"'>";
How do you do a 5th level nested quote?
Include an escaped backslash: \\\"
The important thing to note here, however, is that you've neglected to
remember that an attribute value cannot contain a literal quotation mark
of the same type to delimit the value itself. That is, instead of writing,
""Thanks", he replied." or "\"Thanks\", he replied."
one must write:
""Thanks", he replied."
Likewise if using apostrophes, replacing " with ' :
'That's all, folks!'
HTML neither knows nor cares about backslashes as escape delimiters;
only entities are acceptable.
The end result is string like (manually wrapped and concatenated):
"<tr onmouseover='return overlib(\"<a href='#'"
+ " onclick='getXMLFeed(\\\"price\\\");return"
+ " false;'>Price</a>\");'>"
Or, as I prefer to use double quotes as attribute value delimiters:
'<tr onmouseover="return overlib(\'<a href="#"'
+ ' onclick="getXMLFeed(\\\'price\\\');return'
+ ' false;">Price</a>\');">'
Note that I've removed the use of the javascript pseudo-scheme. Read the
archives for why its use in links is a bad idea.
It might help you in future if you work backwards, starting from (in
this case) the markup you'd really want to pass to the overlib function,
working your way "out" to the markup that would contain that. That said,
it would be easier to move all of that out of the event listener into a
separate function.
Mike