Return to doc.sitecore.com

Resolving JavaScript Issues

There are at least two causes of JavaScript issues: incorrect configuration of a Sitecore client machine and attempting to embed JavaScript in HTML fields.  This document describes resolutions to both.

Sitecore supports a fully patched Internet Explorer 6 and makes the best possible effort to support the latest release of Firefox as well.  Sitecore strongly recommends Internet Explorer for the best possible user experience. 

1.  Sitecore Client and JavaScript Issues

A Sitecore client machine which does not meet minimum requirements or has not been configured correctly may throw JavaScript errors.  On the Sitecore Developer Network (http://sdn.sitecore.net) see Products > Sitecore V5 > Installation Guide > Requirements > Client Requirements (http://sdn.sitecore.net/Products/Sitecore%20V5/Sitecore%20CMS%205,-d-,3/Installation/requirements.html) for a description of minimal Sitecore client environment requirements. 

Patch the operating system and browser:

The CMS server must be added to the Trusted Sites list in Internet Explorer:

Some circumstances can apparently cause browsers to corrupt cached CSS and JavaScript.  To resolve such issues:

Some software firewalls can insert code into JavaScript resources as they are being retrieved by the browser. 

If none of these solutions resolve the issues, send screen shots of the Windows and Internet Explorer version identifiers to the partner or Sitecore support:

2.  JavaScript in HTML Fields

Sitecore strongly discourages attempting to embed JavaScript in fields of type HTML.  

To provide user control of item-level JavaScript, add a field of type Memo to the appropriate template(s) to separate the markup from the code.  For this example, imagine that the field is called Script.

In the appropriate rendering, check whether the Script field is populated and if so, output the opening <script> <!-- tag, the content of the Script field and the closing --></script> tag. 

If it is absolutely necessary to embed the JavaScript in the content of the HTML field, a token can be inserted into the HTML field and the rendering can replace this token with the script tags enclosing the content of the memo field.  Field security can be applied in the template to allow developers to maintain the JavaScript field while non-technical users can only maintain the HTML.