2

I am getting a javascript error "Invalid argument on Line: 2 Char: 141544 in sp.ui.rte.js" on a SharePoint development. This appears to be a known issue from google within the SharePoint js files - http://wss.boman.biz/Lists/Posts/Post.aspx?List=c0143750-7a4e-4df3-9dba-8a3651407969&ID=69 After analysing the impact I decided that rather than changing the js in the SharePoint 14 hive I want to suppress the error message for just this error. I was trying to do the following:

ClientScriptManager cs = Page.ClientScript;

            //Check to see if the startup script is already registered.
            if (!cs.IsStartupScriptRegistered("Alert"))
            {
                StringBuilder cstext1 = new StringBuilder();

                cstext1.Append("<script type=text/javascript> window.onerror = function (msg, url, num) {return true;} </");
                cstext1.Append("script>");

                cs.RegisterStartupScript(this.GetType(), "Alert", cstext1.ToString());
            }

The problem is this will suppress all js errors on the page not just the sp.ui.rte.js ones. Is it possible to do a string search on the URL (http://SHAREPOINT/_layouts/sp.ui.rte.js?rev=uY%2BcHuH6ine5hasQwHX1cw%3D%3D - where the only consistent value between sites will be /_layouts/sp.ui.rte.js? ) to just search and suppress this exact error? Thanks for any help!

2 Answers 2

1

Use try/catch block around code in JS. If message matches something you want to ignore, just do nothing. Propagate everything else.

Your original approach with .onerror would work too if you change it to analyze message and propagate everything not matching ignored string as well.

Sign up to request clarification or add additional context in comments.

1 Comment

I'd rather not change any of the the SharePoint JS if possible is why I decided not to use the Try/Catch method.I was trying to analyze the message but that is where my problem lies. I saw in one thread someone use urlsearch but I was unable to implement this. Thanks for your input thou!
1

So far this has been the most successful fix I have found and currently using:

function fixRTEBug() {
    // 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 Comment

When I try this, I get an error ExecuteOrDelayUntilScriptLoaded() as not defined, so I try to delay that with a document.ready() as they say here: sharepoint.stackexchange.com/questions/31387/… but it still doesn't suppress the hierarchy error. I have more details here: sharepoint.stackexchange.com/questions/164012/…

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.