How to fix scrolling (and other) issues in Chrome on SharePoint 2010

Today I looked deeper into the issues our users have with SharePoint 2010 in Chrome. It seems that Chrome does not always (strange…) executes "onload" within the body tag. However, SharePoint needs to execute one important javascript function there to enable scrolling, the ribbon and some other stuff (also the "ExecuteOrDelayUntilScriptLoaded" function)

Solution

We are already using jquery so this one is the best solution:

   1:  jQuery(document).ready(function () {

   2:      if (window.chrome) {
   3:          jQuery("body").removeAttr("onload");
   4:          if (typeof (_spBodyOnLoadWrapper) !== 'undefined') {
   5:                  _spBodyOnLoadWrapper();
   6:          }
   7:      }

   8:  });

 

Special hint: Do not use "$" in "global" javascript files for jQuery, but instead the explicit "jQuery" object, because in some library types (e.g. Picture Library) the $ has a different meaning in SharePoint.

**UPDATE:

**Added "if (window.chrome)" to check for Chrome, because InfoPath Workflow Init Forms are not working as expected if the __spBodyOnLoadWrapper_ is not executed within the real body onload. So they are not working in Chrome.

Leave a comment




Loading...