I am using Chrome (I know not fully supported) and I wrote a small little script to display the weather using jQuery and Yahoo weather.

The problem is once I placed it on the page, some parts of the ribbon (edit, page, browse, publish) no longer work in Chrome. Now while I know Chrome is not supported, it worked before.

This is my 1st little test in using jQuery within SharePoint, I launch the developer tools in Chrome (F12) to view the console and there are no errors.

Is there any other way I can try to debug what is happening?


This is most likely because the <body> attribute onload is not reached, or even overwritten by jQuerys document ready.

You can fix this by calling _spBodyOnLoadWrapper(), for example like this:

$(function() { 
  (window.navigator.userAgent + '').match(/Chrome/) && 
    !_spBodyOnLoadCalled && 
    window._spBodyOnLoadWrapper && 
| improve this answer | |
  • Do I put this in the same script in my weather widget? – mdumka Nov 27 '12 at 15:50
  • Anywhere you like really, for example with script link. But to test this solution you can open up your console (F12) and run _spBodyOnLoadWrapper(), if this works you should immediately see improvements. – eirikb Nov 27 '12 at 19:08
  • My god man ... you are a lifesaver! Thanks soooo Much! – mdumka Nov 29 '12 at 18:21

I've never had any huge issues with the combination of Chrome, jQuery, and SharePoint that I can remember. Where are you calling your jQuery script? Header? Footer? And what are you calling your scripts on? I typically call on

  // script here

and have never had problems in the past. Can you paste any kind of code sample? I can't confirm @eirikb's solution, but it sounds like it might help.

| improve this answer | |

I would fix your issue by simulating JQuery's way of doing things and use an iifee to wrap your code up giving yourself localised variables.

The JQuery iife (Immediately invoked function expression) looks like this:

(function(window,document,undefined) {
    ... code here

this refers to the window object in this case.

JQuery should never overwrite the document because of this, it actually has it's own copy to play with, so if it is then some thing's are broken with your JQuery.

So make yourself an instanced version of the page, and you should be fine for calling your functions, it's also good practice while working with any code to scope your variables, and iifes are used to scope variables in Javascript.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.