2

I was trying to include a field value in windows.location of JavaScript which have combination of apostrophe, single quote and double quote. Is there any way I can handle this string combinations?

  • Can you provide an example string, & the code you tried using? – battery.cord Feb 5 '18 at 14:40
  • My sample field value is '"Someone`s Name"'. And I'm trying to solve this using encodeURI in JavaScript. – r.tolentino Feb 5 '18 at 14:50
2

Use JSENCODE to get it to proper JavaScript escaping, and then encodeURIComponent to make sure the URL is correct.

Example Code:

var someonesName = "{!JSENCODE(Contact.Name)}";
var someUrl = "https://.../?name="+encodeURIComponent(someonesName);

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.