Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Lee 1130 posts 3088 karma points
    Nov 29, 2010 @ 11:31
    Lee
    0

    Output escaped HTML for JavaScript

    I am trying to output the contents of my RTE into a JS string in my XSLT, but having issues with the quotation marks not being escaped.

    I started along this line, but the XSLT doesn't like it

    <xsl:value-of select="normalize-space(umbraco.library:Replace(./bodyText, '"""', '\"""'))" disable-output-escaping="yes" />

    Is there a method already to get an HTML string ready for JS??

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Nov 29, 2010 @ 11:55
    Chriztian Steinmeier
    0

    Wow... looks like dangerous territory :-)

    Do you have a small snippet of the HTML from the RTE?

    (I'm a bit confused about the triple quotes you've got in that statement - those wouldn't even work correct in HTML would they?)

    /Chriztian 

  • Lee 1130 posts 3088 karma points
    Nov 29, 2010 @ 12:08
    Lee
    0

    Its just some text with a link, maybe they'll put an image in too but that is a bit irrelevant - The above is just an example of what I have tried (As well as Replace(./bodyText, '"', '\"') and other variations).  I just need to escape " so the JavaScript can read the string \".

  • jaygreasley 416 posts 403 karma points
    Nov 29, 2010 @ 12:30
    jaygreasley
    0

    Well, in Javascript the backslash is enough to escape a single quote (as you have tried) so maybe the problem is not the escaping?

    are you getting a nice useful js error? ;-)

  • Lee 1130 posts 3088 karma points
    Nov 29, 2010 @ 12:32
    Lee
    0

    No its the XSLT not liking it... Its to do with the quote " in the value-of?

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Nov 29, 2010 @ 12:35
    Chriztian Steinmeier
    1

    Try this, then:

    <xsl:value-of select="umbraco.library:Replace(bodyText, '&quot;', '\&quot;')" disable-output-escaping="yes" />
    
    
    

    /Chriztian

  • Lee 1130 posts 3088 karma points
    Nov 29, 2010 @ 12:38
    Lee
    0

    Oh My God! Its definitely Monday... That is it, so bloody obvious! Thanks Chriztian I'll try it in a minute and apply some Karma for you :)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies