[SharePoint 2010] JavaScript Errors in sp.ui.rte.js and sp.ui.rte.debug.js

In SharePoint 2010, there is a bug in the SP.UI.RTE.js file (and it’s debug version) that causes a JavaScript error in a few different situations. For myself, it was occurring when using the TaxonomyWebTaggingControl on a custom application page. Others have noticed the error with form validation.

The issue is caused by a null reference exception that isn’t caught in a try-catch block or other type of error handling.

James Boman posted a solution that involves editing these files on the hard drive. I agree with his sentiment in the post that this is a really bad idea for a few reasons: 1) Microsoft doesn’t support your environment if you mess with their files, 2) any updates to SharePoint (and sometimes Windows) will override your changes, and 3) you could do more damage than good.

With that said, however, using his modified code, we can override the offending code with some additional JavaScript rather than editing Microsoft’s code. In this function, we first ensure that the function is not undefined. Then, we replace the specific function with a fixed version of the function. It’s not the prettiest fix, however it sure beats editing Microsoft’s files.

In my project, I am loading this JavaScript on every page using an AdditionalPageHead control.

Hopefully you find this useful.


  1. A slightly better solution which us CU proof for the part that is fixed according to this blog but also adds in a fix for RTE.Canvas.checkCurrentFocus to fix error in console.

    function fixRTEBug() {

    if (typeof ngSharepointVersion === ‘undefined’ || ngSharepointVersion !== 14)


    if (typeof RTE.Canvas.checkCurrentFocus !== ‘undefined’) {

    RTE.Canvas.checkCurrentFocus = function() {ULSkay:;

    var $v_0 = RTE.Selection.getSelectionRange();

    if ($v_0) { //this is different from SP to avoid error in console

    var $v_1 = $v_0.parentElement();

    if (RTE.Canvas.isInEditable($v_1) && !RTE.Cursor.get_range().isValid()) {







    // This Fix for parentElement bug in RTE should survive Service Packs and CU’s

    function SubstituteRTERangeParentElement() {

    var originalRTERangeParentElement = RTE.Range.prototype.parentElement;

    RTE.Range.prototype.parentElement = function () {

    try {


    } catch (e) { }





    • dantuck: Nice! +1



  1. Share Point | - [...] [SharePoint 2010] JavaScript Errors in sp.ui.rte.js and sp.ui.rte.debug.js | John Chapman’s Sh... [...]
  2. Dynamic Forms for SharePoint: Now with side-by-side « SharePoint JavaScripts - [...] Fixed a bug in SP.UI.RTE.js that occurs when hiding rich text columns in SP2010. The workaround is provided by …

Submit a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Pin It on Pinterest

Share This