I have a string I would like to escape to insert variable. Cannot successfully escape the string.

'<a href="/'+result.Id+'" id="'+result.Id+'" position="relative" onmouseover="LookupHoverDetail.getHover('+result.Id+', '/'+result[i].Id+'/m?retURL=%2Fresult.Id&isAjaxRequest=1').show();" target="_blank">'+result.Name+'</a>';

This is only part of the string but I can't seem to escape the string in the second parameter of the getHover attribute.

  • 1
    where you wan't to escape it? In JS, Apex or somewhere else?
    – Ashwani
    Feb 16, 2015 at 15:58
  • I want to escape it in Javascript.
    – Berg
    Feb 16, 2015 at 16:00
  • @Ashwani, I thought the escape character is same in both JS & Apex - the backward slash character.
    – Jarvis
    Feb 17, 2015 at 19:08

1 Answer 1


Try to understand how it is escaped. Perhaps you may not get such help from here always.

'<a href="'+result.Id+
'" id="'+result.Id+
'" position="relative" onmouseover="LookupHoverDetail.getHover(\''+result.Id+
'\', \''+result[i].Id+
'/m?retURL=%2Fresult.Id&isAjaxRequest=1\').show();" target="_blank">'+

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.