www.webdeveloper.com
Results 1 to 3 of 3

Thread: encodeURIComponent fail

  1. #1
    Join Date
    Aug 2011
    Posts
    1

    encodeURIComponent fail

    I have an incoming message hitting my XSL 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, nature. It will give me the error, nature is undefined.

    Any ideas on how to use encode for both scenarios?

    Thanks!

  2. #2
    Join Date
    May 2011
    Posts
    194

    maybe this ...


  3. #3
    Join Date
    Feb 2003
    Location
    Michigan, USA
    Posts
    5,774
    You'll need to encase the XSL tag in quotes:
    Code:
    parent.myForm.hiddenValue.value = "<xsl:value-of select="INCOMING/MESSAGE/BLAH">";
    And then you'll need to escape quote characters at the XSL layer. Better yet, the data within the XML should not have raw quote characters. They should all be encoded as [ampersand]quote;

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles