Content Editor Web Part JavaScript Error
15. May 2008 05:28

After installing SharePoint (MOSS) SP1, I ran into a problem with many of my Content Editor Web Parts (CEWP) wherein when you press 'edit' instead of showing the nice toolbar, you get a javascript error.

image

"Object does not support this property or method"  on line 169.

I debugged the javascript using Visual Studio, and it was immediately apparent that a string cast was needed in line 168 of assetpicker.js.

You can find this javascript file here:

Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033\assetpicker.js

The area of code in question looks like this:

    for( var i in propArray )
{
var nameValuePair=propArray[i].split("=");
if(nameValuePair.length==2)
{
objectToPopulate[nameValuePair[0]]=decodeURIComponent(nameValuePair[1]);
}
}


The line in question is where the variable 'nameValuePair' is created, and assigned the value from propArray[i].split("=").  The members of propArray aren't strings, and as such the split command isn't available.



Change that one line to use a javascript string cast.  Which can be done by wrapping "String(...)" around the array.  (In red below)



    for( var i in propArray )
{
var nameValuePair=String(propArray[i]).split("=");
if(nameValuePair.length==2)
{
objectToPopulate[nameValuePair[0]]=decodeURIComponent(nameValuePair[1]);
}
}


That change is on line 168.  Try making it in the javascript, and clear your temporary internet files/browser cache, then revisit your SharePoint site.  The toolbar should show up now.

Tags: Comments (0) | Permalink

Comments

Comments are closed