Thursday, August 16, 2012

SharePoint 2010 - Improving Chrome Support

Certainly, if you've utilized Google Chrome to browse SharePoint 2010 pages you've noticed the inflexible behavior caused by the on-demand javascript. You almost always have to refresh to ensure that the javascript functionality works - Modal Dialogs, Ribbon, etc.

With some minor updates to the master page, you should be able to utilize Google Chrome without any problems.

Firstly, you'll want to add some additional items in the <head> tag.




Afterwards, at the bottom of your page just above the closing </body>, add the following javascript.

    // Attempt to detect if this is iframe content
    if (location.href == top.location.href) {
        if(navigator && navigator.userAgent && 
          /chrome/.test(navigator.userAgent.toLowerCase()) && $){
          $(document).ready(function(){
            if(_spBodyOnLoadWrapper){_spBodyOnLoadWrapper();}
            if($("#s4-workspace") && $("#s4-ribbonrow")) {
              $("#s4-workspace").height($(window).height() - 
              $("#s4-ribbonrow").height());
            }
          });
        }
    }

That's all it should take and your ribbon and modal dialogs should be responsive.

Javascript, taken from http://social.msdn.microsoft.com/Forums/br/sharepoint2010general/thread/94b89c35-5136-4fc5-86d6-9f8524325e55