Home > Development, JavaScript, Master Page, Page Layouts, SharePoint 2007, Sharepoint 2010, Web Part > Fix: Content Editor Web Part Rich Text Editor Popup fails to display

Fix: Content Editor Web Part Rich Text Editor Popup fails to display

 

Introduction

This problem has been bugging me for the past 3 days and so I thought I’d be kind and document it just in case it has been causing someone else problems.

So the issue is with the SharePoint 2007 Content Editor Web Part and when you edit the web part and click the button to show the Rich Text Editor you get a JavaScript error.

There does seem to be another post on MSDN (http://social.msdn.microsoft.com/Forums/en-NZ/sharepointcustomization/thread/90e14ff3-7003-44fd-9b4c-d9e654f7d8e1 that was showing the same issue and although the fix was related, the fixes that were specified in this post didn’t help me.

 

Issue

So as I have already mentioned when using the SharePoint 2007 Content Editor Web Part’s Rich Text Editor Dialog you get the following JavaScript error:-

Invalid Argument in HtmlEditor.js at line 5740, character position 2

On further investigation it is this line in the HtmlEditor.js file that is causing the problem.

elem=document.getElementByid(containerId);

Actually if you follow the JavaScript code then the issue seems to be down to the piece of JavaScript where the web parts are registered on the page. At the bottom of each SharePoint page is a section of JavaScript that looks something like this:-

 1: <script LANGUAGE='Javascript'>


 

 2: <!--


 

 3: WPSC.Init(document);


 

 4: var varPartWPQ1 = WPSC.WebPartPage.Parts.Register('WPQ1','[GUID]',document.all.item('WebPartWPQ1'));


 

 5: WPSC.WebPartPage.WebURL = 'http:\u002f\u002fsharepointurl';


 

 6: WPSC.WebPartPage.WebServerRelativeURL = '\u002f';


 

 7: //-->


 

 8: </script>

It seems that the JavaScript which creates the varPartWPQ1 variable does not work properly as the varPartWPQ1 is created without populating its ID property. This ID property is the value that is assigned to containerId in the line:-

elem=document.getElementByid(containerId);

 

The Solution

After a lot of trial and error I found that it was to do with the master page and a <meta> tag within the master page’s <head> tag.

The tag causing the problem is this one:-

 1: <meta http-equiv="X-UA-Compatible" content="IE=8" />

Removing this line and redeploying the master page fixed the JavaScript error.

This meta tag tells IE to run in IE 8 Standards mode which seems to cause a problem with the browser when its trying to get a document item using the function document.all.item([itemid]).

For more information on the <meta> tag please see the following article on Defining Document Compatability (http://msdn.microsoft.com/en-us/library/cc288325(VS.85).aspx)

 

Further Information

The reason for this happening was actually that the master page was being ported back from a SharePoint 2010 master page to a SharePoint 2007 master page.

This tag was left in from the SharePoint 2010 master page.

I really do hope this helps someone as it drove me mad for a while.

About these ads
  1. December 19, 2012 at 12:27 | #1

    I’m having the same problem on a SharePoint 2007 site, but I’m trying to find another solution. Unfortunately this one didn’t worked for me…
    Obs.: it only occurs on some browsers mode, for example IE8. On IE7 works fine!

  2. December 20, 2012 at 17:28 | #2

    I finally solved using a similar approach, but enforcing the compatibility to IE 7 (all clients were using IE8 with the default browser mode – that’s IE 8 ;p)

    Recomendations on following link:

    http://msdn.microsoft.com/en-us/library/ee354191.aspx

    Please read the “SharePoint HTML and Internet Explorer 8″ topic.

  3. December 20, 2012 at 17:29 | #3

    Finally solved using a similar approach, but enforcing the compatibility to IE 7 (all clients were using IE8 with the standard mode – that’s IE 8 ;p)

    Recomendations on following link:

    http://msdn.microsoft.com/en-us/library/ee354191.aspx

    Please read the “SharePoint HTML and Internet Explorer 8″ topic.

    • December 20, 2012 at 17:53 | #4

      Hi,
      Really appreciate the time that you have taken out to give me another alternative. I will take a look at that post and update this post, crediting you with the additional findings.

      Regards
      Simon

  1. No trackbacks yet.

Thoughts? Comments about this post? Please leave them here..

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: