How do I deal with apostrophe in user name while passing variable to JavaScript?

  • 0
  • 1
  • Question
  • Updated 2 years ago
  • In Progress

I pass a variable of Current User to a javascript page.  It works fine unless the name includes an apostrophe (O'Neil). 

The formula includes: "var Cuser = '" & URLEncode(User()) & "';" & 

How would I change this to not error out if name includes an apostrophe? 

BTW the error if user name has an apostrophe is : SCRIPT1004: Expected ';'

Thanks

Photo of Bill

Bill

  • 0 Points

Posted 3 years ago

  • 0
  • 1
Photo of Matthew Neil

Matthew Neil

  • 31,678 Points 20k badge 2x thumb
Try making any of these adjustments to your variable definitions.

http://stackoverflow.com/questions/19399610/passing-a-parameter-to-function-with-single-quote