The problem will occur if you pass a literal string to the showTip() function using single quotes around the string (
showTip('like thisexample') ). In that case, the additional apostrophe in the string is interpreted as the end of the string, and then there's a bunch of other stuff folowing it that doesn't beong there. It gets harrier if you're passing it in a js call in the url attribute of a static link
<a url="javascript:showTip('like ths example')">click me</a>, because people will ften enclose the url argument in double quotes, leaving single qutesas the only thing left in the call to showTip().
I'm rambling.... it's late.
Anyway.. this is a general problem with string handling in js, not something specific to the menu or to the tooltips add-on. Your suggestion of using an html code is a good one. I find that another approach would be to escape the single quote so that it is interpreted literally, as part of the string. "Escaping a quote" is accomplished by placing a backslash in front of it, like so:
\'.
Code: Select all
showTip('A single quote as an apostrophes shouldn\'t be a problem here, because it\'s escaped.')
Cheers,
Kevin