I’m trying to create a link as follows in HTML:
<a href="javascript:void(0) onclick="print(string)">
I’m doing this using JQuery as follows:
html = '<a href="javascript:void(0)" onclick="print(\'' + string + '\')">'
However, I run into problems when string itself contains a single quotation mark. Is there any way that I can do something of this sort regardless of the characters contained in string? The main ones I’m trying to figure out are both single and double quotation marks.
Best, and thanks for any advice,
Sami
You could do this quite easily by simply encoding the string as a URIComponent before placing it in and then decoding it when you need it.
ie.