javascript confirmation with html character code

I know this has nothing to do with CI, but I hope somebody knows the answer.

Admins have a list of all the items they have added, and trying to make everything as safe as possible, the only think that is not working is the javascript confirmation, such as the following:

return confirm('Are you sure you wish to delete Don't be sad?');"

That is attached to a link when the user clicks on it, they will get that confirmation, but in this case that character ' is the single quote, so it shouldn't be a problem with javascript since it's safe. But it is not, when items such as that with single quote, gets clicked, the user does not get a confirmation, but it gets deleted right away,

Is there any way around this?


Even though it is an entity, javascript still interprets it as a single quote. You still need to make sure you are escaping the entity version of it with a backslash.

var string = 'ampersand & woot & and &<';
    string = string.replace(/&/gi,'\&');

Thanks for the reply, that will solve the problem.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.