Wednesday, 14 November 2007

I have been working with SharePoint quite a bit over the past few months. At Netstore we are building an AA accessible website for our client using XHTML with a CSS based layout.

I recently came across a problem where I had a WebPartZone in a page, and when I tried to drag the webparts around I get the javascript error "Object Required". Fortunately, a bit of googling led me to this post - CSS causes JavaScript error while moving Web Parts in edit mode where I learned the issue is due to the zones being placed in elements with a CSS style of position:relative.

Unfortunately I had to fix the bug to pass UAT so I was left with two options - either change the CSS to remove the relative positioning or try to fix the JavaScript. Given that we were working with HTML/CSS delivered by an external design agency (which I didn't want to mess with) I decided to go with the latter.

The blog entry indicated that the problem lay in a Microsoft function called MSOLayout_GetRealOffset. This function is defined in <12>\TEMPLATE\LAYOUTS\1033\IE55UP.JS. I didn' t fancy changing this file as it would present a deployment nightmare, but fortunately with JavaScript, you can override a global function by just defining it later on in the HTML. Therefore I was able to redefine this function in my master page and fix the error. Here is the new version of the function:

That isn't one I've seen... I can only suggest you trace the javascript through to the work out where it's happening.

I often use Firebug to trace JS errors, but unfortunately Sharepoint renders different javascript if you are using firefox, so that doesn't work. I could only suggest going into the 12 folder and tracing it through using alerts.

If you discover anything more, or can send me something easy to reproduce, I will look into it further.

I tried, using the above javascript in my page, for a moment it looked like the problem is gone, but after performing couple of drag & drop actions for the webparts i get following javascript errorUnspecified errorline 1617char 2

I'd love to help, unfortunately I am not working with Sharepoint at the moment so I can't test this any further. Can I suggest you attach Visual Studio Debugger to your iexplore process (make sure you enable script debugging first) and you should be able to get some more information about where this was happening?ThanksNeil

Thanks for this. I would really like to know what caused it as until recently it was working fine and I had made no CSS or master page changes which might have introduced the relative positioning you describe.

However, in the interests of project deadlines, analysis can wait - your solution works great!