syntax error

Jihae Chung's Avatar

Jihae Chung

30 Apr, 2015 08:38 PM

I am using a .js file in Cascade that does this function.

<script type="text/javascript">
$(document).ready(function() {
  var bodyHeight = $("body").height();
  var vwptHeight = $(window).height();
  if (vwptHeight > bodyHeight) {
    $("footer#colophon").css("position","absolute").css("bottom",0);
  }
});
</script>

In the script file, it looks fine but when I go to the page that uses the script file and go to "source" I see that ">" symbol autocorrects to &gt; and breaks the function. How can I write so that it doesn't autocorrect ">" symbol??

Thanks,

J

To unsubscribe from this group and stop receiving emails from it, send an email to [email blocked].

  1. 1 Posted by Jihae Chung on 01 May, 2015 02:11 PM

    Jihae Chung's Avatar

    Hi Support,

    Just following up on my request. Can you please help?

    Thanks,

    J

    From: Jihae Chung
    Sent: Thursday, April 30, 2015 4:38 PM
    To: '[email blocked]'
    Subject: syntax error

    I am using a .js file in Cascade that does this function.

    <script type="text/javascript">
    $(document).ready(function() {
      var bodyHeight = $("body").height();
      var vwptHeight = $(window).height();
      if (vwptHeight > bodyHeight) {
        $("footer#colophon").css("position","absolute").css("bottom",0);
      }
    });
    </script>

    In the script file, it looks fine but when I go to the page that uses the script file and go to "source" I see that ">" symbol autocorrects to &gt; and breaks the function. How can I write so that it doesn't autocorrect ">" symbol??

    Thanks,

    J

    To unsubscribe from this group and stop receiving emails from it, send an email to [email blocked].

  2. 2 Posted by Ryan Griffith on 01 May, 2015 02:50 PM

    Ryan Griffith's Avatar

    Hi J,

    To clarify, is the <script> tag you provided within a page, block, or file? If it is in a page or block, how are you entering the content (eg text field or WYSIWYG)?

    Also, have you tried surrounding the code with a CDATA #protect code section? For example, you would have something like the following:

    <script type="text/javascript"><![CDATA[#protect
    $(document).ready(function() { 
      var bodyHeight = $("body").height(); 
      var vwptHeight = $(window).height(); 
      if (vwptHeight > bodyHeight) { 
        $("footer#colophon").css("position","absolute").css("bottom",0); 
      } 
    }); 
    #protect]]></script>
    

    Please let me know if you have any questions.

    Thanks!

  3. 3 Posted by Jihae Chung on 01 May, 2015 03:02 PM

    Jihae Chung's Avatar

    Hi Ryan,

    I used the <script> tag both in .js page and inside the template. In both places were still converting “>” tag to &gt;. Also, the code I sent you somehow added "><![CDATA[#protect” tag. Anyway, I am using a different <script> tag since I wanted to this project done. But I would still like to know what I have to do next time when I need to use “>” symbol.

    Thanks,

    J

  4. 4 Posted by Ryan Griffith on 01 May, 2015 03:30 PM

    Ryan Griffith's Avatar

    Thank you for following up, J. I am glad to hear you were able to work around the character being encoded.

    The character was encoded because the resulting content needs to be validated as XML. By wrapping the content in a CDATA tag, you are essentially saying the content within is known to be invalid XML and won't be validated as such; which should leave the character intact.

    I used the <script> tag both in .js page

    So you had the script tag within the .js file? I think this is technically not valid, but either way the character should not have been rewritten within a file asset since it is not validated as XML.

    I'm going to go ahead and close this discussion, please feel free to comment or reply to re-open if you have any additional questions.

    Have a great day!

  5. Ryan Griffith closed this discussion on 01 May, 2015 03:30 PM.

  6. Jihae Chung re-opened this discussion on 01 May, 2015 04:19 PM

  7. 5 Posted by Jihae Chung on 01 May, 2015 04:19 PM

    Jihae Chung's Avatar

    Got it. Thank you!

  8. Ryan Griffith closed this discussion on 01 May, 2015 05:22 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac