Home
Developers

Developers

  • Documentation
    • Developer Guide
    • API Reference
    • Style Guide
    • How-To
    • Troubleshooting
  • Submit a Flake
  • Support

Pageflakes How-To and Troubleshooting Guide

  • Manage Flake Instances
  • Server-Side Scripting
  • Auto-Save Settings
  • Storing an Array into a Profile
  • Using CSS
  • Access Web Services from Flakes
  • Flake Development Tools
  • Troubleshooting
    • Using the "id" element correctly
    • Using XMLHttpRequest
    • Issues with Internet Explorer, Firefox and Opera
    • Use CDATA inside script blocks
    • Avoid memory leaks and understand 'this'
    • Minimize processing in load()
    • Do not use alert()
    • Do not use <form> elements
Home » Documentation » How-To » Troubleshooting

Use CDATA inside script blocks

Using < or > signs inside <script> tags is problematic, even if it is enclosed in double quotes. For example:

<script> body.innerHTML = "<a href='test.html'>Test</a>"; </script>

will fail because the < sign is invalid inside a script tag when it is parsed. So, use CDATA sections for such script blocks. For example:

<script><![CDATA[ body.innerHTML = "<a href='test.html'>Test</a>"; ]]></script>

If you see that your script blocks are not getting processed at all and the functions you are trying to access are completely unavailable, then this might be the reason.

This can also be a problem with for loops. If the script is not enclosed in CDATA, then the following example will fail:

for(var i = 0;i<10;i++)

We need some space before and after the "less than" (<) sign. Otherwise when we parse the flake file, "<10;" appears as a tag in the flake HTML file. Putting a space after the "<" characters prevents it from becoming a tag.

for(var i = 0; i < 10; i ++)

However, the preferred mechanism is to include the script in a CDATA element, and the whitespace is no longer an issue.

‹ Issues with Internet Explorer, Firefox and OperaupAvoid memory leaks and understand 'this' ›
»
  • Printer-friendly version