A JS error and a redirect occurs when editing a RichHtmlField twice

A strange problem started occuring with the RichHtmlField. When using IE8 in a SharePoint site, after editing a RichHtmlField the second time, a JavaScript error is thrown in form.js and the user is redirected to the welcome page of the site.

I'm still not sure what triggered this strange behaviour, if it is something specific to this site or a general problem. What I found out is that this occurs in IE8.

Here is how to duplicate this issue:

  • You edit a RichHtmlField (clicking where it says "Edit Content").
  • Then you click somewhere else on the page.
  • Now go and edit the same field again.

If you have the same issue, after doing this, a JavaScript error will be thrown:

Message: 'null' is null or not an object
Line: 2325
Char: 2
Code: 0
URI: (...)/form.js?rev=df60y6YolDjUVbi91%2BZw%2Fg%3D%3D

Unfortunately this is not all that happens. After the error, the user will be redirected to the welcome page of the site.

It's something that occurs in the form.js file, so I'm not sure if this is something that can be fixed by configuration.

The workaround I implemented is not entirely pleasant, but it also solves other issues with default SharePoint installations. Basically what I did was make IE8 render the site as if it were IE7.

You can do this in several ways. For example, you can put a meta tag in your masterpage:

<meta content="IE=EmulateIE7" http-equiv="X-UA-Compatible" />

Another alternative is to add an HTTP header to the site in IIS with:

X-UA-Compatible: IE=EmulateIE7

You can read more about emulating IE7 for IE8 here.

Nuno Freitas
Posted by Nuno Freitas on October 28, 2013

Related articles