JS encodeURIComponenet not working
I have an incoming message hitting my X开发者_运维百科SL page. On this XSL page I have javascript to catch it and place the items in the appropriate places.
There is the possibility that these messages can have double quotes and other escape characters.
I am using
parent.myForm.hiddenValue.value = encodeURIComponent(<xsl:value-of select="INCOMING/MESSAGE/BLAH">)
This works if the message has special characters but seems to give me a JS error if it does not. If the value coming in is nature. It will give me the error, nature is undefined.
Any ideas on how to use encode for both scenarios?
Thanks!
It sounds like you're not quoting the string that you're passing to the function e.g.
encodeURIComponent("nature")
FIGURED IT OUT Place single quotes around XSL
encodeURIComponent('<xsl:value-of select="BLAH/BLAH/BLAH"/>')
精彩评论