17

I'm setting up an SP2010 VM for dev testing purposes. Our vanilla install has no other components present and is throwing JS errors in Chrome and Firefox. In Firefox (v13):

a is null
http://hovmdvmrg06/_layouts/sp.ui.rte.js?rev=aTi1rujCmyK4y06NVUncdQ%3D%3D
Line 2

In Chrome (current):

Uncaught TypeError: Cannot call method 'parentElement' of null /_layouts/sp.ui.rte.js?rev=aTi1rujCmyK4y06NVUncdQ%3D%3D:2

This is a major blocker for me to test some JS I'm working on and my searches for the error isn't turning anything up. I don't know if it's related, but IE has an HTML warning:

HTML1114: Codepage unicode from (UNICODE byte order mark) overrides conflicting codepage windows-1252 from (11)

Opera 11 doesn't seem to throw the error either.

4
  • What is the patch level of the 2010 vanilla farm? Jun 12, 2012 at 14:56
  • I just checked this. It's at 14.0.6114.5001 Jun 12, 2012 at 16:05
  • 4
    Welcome to Microsoft Sharepoint quality coding... Feb 20, 2013 at 15:55
  • i tried all the above fixes, still i am getting this error whenever i am trying to edit a page or create new page Uncaught TypeError: Cannot read property 'parentElement' of null at RTE.Canvas.checkCurrentFocus i am using v4.master as masterpage.
    – Barry
    Jul 15, 2017 at 4:57

6 Answers 6

4

You can also fix in this way.

SP.SOD.executeFunc('sp.ui.rte.js', null, function () {
    if (/var \$v_0 = RTE\.Selection\.getSelectionRange\(\);[\r\n\t ]*var \$v_1 = \$v_0\.parentElement\(\);/.test(RTE.Canvas.checkCurrentFocus.toString())) {
        var _oldCheckCurrentFocus = RTE.Canvas.checkCurrentFocus;
        RTE.Canvas.checkCurrentFocus = function () {   
            if(RTE.Selection.getSelectionRange())
                return _oldCheckCurrentFocus();
        };
    }
});

Use SP.SOD.executeFunc to wait until RTE library is loaded, once it's loaded you first save the original implementation then test if it still has the bug using a Regular Expression, if the bug is there you override the original funcion with a version which will not cause the error.

But note that I did not override it completely, the new function check if RTE.Selection.getSelectionRange() returns a valid object, if it does the old implementation is executed, otherwise the function ends.

This way we do not mess so much with native code, and if Microsoft fix it your code will not override their funciton anymore automatically. And if Microsoft changes the function but keep the bug we guarantee that when the selection exists we will continue executing the newest implementation.

5

I have seen a bug in the SP.UI.RTE.js file that Microsoft has still not resolved. To fix it on environment where I have seen behavior like this, I add the following JavaScript to the master page:

    function fixRTEBug() {
    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()) {
                    RTE.Cursor.updateRangeToCurrentSelection();
                    RTE.Cursor.update();
                }
            }
        }
    }

    // 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 {
                originalRTERangeParentElement();
            } catch (e) { }
        }
    }
    SubstituteRTERangeParentElement();
}

ExecuteOrDelayUntilScriptLoaded(fixRTEBug, "sp.ui.rte.js");
1

Only after SharePoint SP1 with Cumulative Update from April 2012 is Chrome almost "fully" supported as it has been announced in May 2012 on the Support site http://technet.microsoft.com/library/cc263526#supportmatrix

I would go for installing at least Service Pack 1, June Update and Refresh, and try again!

5
  • and this would be related to Firefox as well? Just checked, and we're already at 14.0.6114.5001 - latest version afaik Jun 12, 2012 at 16:00
  • Are you using any DOCTYPE on your page? Did you closed all <script> tags with <script></script> when referring external scripts and not simple <script /> Jun 12, 2012 at 16:13
  • Nope. this is a strictly vanilla install - we literally installed it, took a snapshot, and started browsing the default pages (et. all) to check this thing out. Note that we originally thought we goofed on the install, so we created a fresh VM - same result. Jun 12, 2012 at 17:35
  • As C. Marius mentioned, it is almost supported, even to this day, SP2010 is not fully supported (still has scrolling issues).
    – Russell
    Jan 9, 2014 at 6:53
  • However SP2013 works as well in Chrome/firefox/safari (FWIHT) as IE.
    – Russell
    Jan 9, 2014 at 6:54
0

You can actually load debug versions for js files and see exactly where it crashes. To do this, got to app pool web config, typically to C:\inetpub\wwwroot\wss\VirtualDirectories\80\web.config and set

compilation : debug=true

<compilation batch="false" debug="true">

I had a similar issue and it was fixed after a windows update.

0

Adding this to my master page fixed just about all of my Chrome issues

$(function(){   


        $.browser.chrome = (typeof window.chrome === "object");

        if($.browser.chrome)
            Reinit();
    });
    function Reinit()
    {
        if(typeof(_spBodyOnLoadWrapper) != "undefined")
        {
            if(_spBodyOnLoadCalled == false)
                _spBodyOnLoadWrapper();
        }   
        else
            setTimeout(Reinit, 10);
    }
-1

Just disable WIKI page home page feature from site

1
  • Please add detailed information or provide links to support your answer. A one liner is not treated as a good answer. Nov 14, 2014 at 18:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.