I'm inserting content with js, that includes an onclick call to a function. This function passes a parameter which contains a database entry, which could contain a '
.
var action = '<a href="#" class="facebook-share" onclick="facebookWallPost(\' '+name+'\')">Share</a>';
Trouble is that when name contains a single apostrophe it breaks the function call. I've tried doing a string replace on name to replace '
with '
but this seems to still be converted back to a '
by the browser.
Any idea how I can get around this?