Posts Tagged ‘ Javascript

Escape Characters

I had an issue today working with a web page and using a javascript function to display pop up text. The data I was working with were file paths.

EBREPORTS\790065TMC232009.QVW,
EBREPORTS\56165TMC202009.QVW,
EBREPORTS\456417TMC262009.QVW,
EBREPORTS\371356TMC502009.QVW,
EBREPORTS\83620TMC372009.QVW

After handing this data to the Javascript function to create the popup box, I was getting strange results. See the image attached. Turns javascript was seeing the backslashes and recognizing them as escape characters. I fixed this by doing a string replace on the text before I handed it to the javascript function.

strDocNamesQV1 = Replace(x.value,”\”,”\\”)

This gave me my desired results.

Share