jquery ">" getting replaced with ">" | Community
Skip to main content
Charles_Sander1
New Participant
March 6, 2017
Solved

jquery ">" getting replaced with ">"

  • March 6, 2017
  • 3 replies
  • 4318 views

I've got a pretty simple javascript being dropped into a landing page. I created an editable field in the template, so that should I need any javascript on a page, I can just add it when I'm setting a new one up. (in template like this: )

     <script>

            // <![CDATA[

                 {{my.Footer js}}
            // ]]>
      </script>

But... I just ran into an oddball issue. I dropped in a really simple JS and it's converting my "greater than" symbol to html character. Is there a way to prevent this, or does somebody know maybe another way to do the below and avoid the problem? the script won't fire because it's showing "&gt; -1" EDIT: I should add that I did try to escape it with />, but that didn't work either.

$(document).ready(function () {

if (window.location.search.indexOf('choice=chocolate') > -1) {

    alert('yes choc');

} else {

    alert('no choc');

}

});

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by

What token type are you using? Sounds like your token is being encoded, if you are using a guided lp and string field you can add the allowHtml="true" attr and should be fine.

3 replies

SanfordWhiteman
New Participant
March 6, 2017

Not clear what you mean by "editable field" here... if it's a mktoText in a Guided LP, for example, it'll work.

P.S. No need to wait on DOMContentLoaded ("ready"). document.location.search exists the moment the document starts to load.

Charles_Sander1
New Participant
March 6, 2017

Ah... the type of field must've been the problem. I was using mktoString, not mktoText. When I changed to mktoText, it worked fine, and didn't overwrite the ">". Maybe it's some protection against injecting script?  Only problem left is the field keeps adding a <div><br /></div> above the code. Doesn't seem to be affecting my layout, but I don't really want that there.

Charles_Sander1
New Participant
March 6, 2017

oh... and I just saw Tony Tiexiera's answer. Maybe I'll go back to that, so I don't have to deal with the <div><br/></div>

Accepted solution
March 6, 2017

What token type are you using? Sounds like your token is being encoded, if you are using a guided lp and string field you can add the allowHtml="true" attr and should be fine.

Charles_Sander1
New Participant
March 6, 2017

update - I solved the problem of > with !=... but that doesn't seem like the best approach. maybe I'm overthinking it.