Jump to Section
1. The Problem
I was testing my SharePoint 2010 branding efforts in Safari 5.1 when I came across the bug shown in Figure 1. The error reads “TypeError: ‘undefined’ is not a function (evaluating ‘b.cloneNode(!0).click()’). This signifies that there is some code in jquery.min.js that isn’t working. The error occurs in Safari 5.1 when I import the jquery.min.js library on SharePoint 2010 pages with an Excel Web Access web part. I was using jQuery 1.11.1 because it was the newest version of jQuery that supported older versions of Internet Explorer. I later determined that jQuery 1.11.1 doesn’t play nicely with SharePoint in this specific scenario.Figure 1
2. The Solution
I waged war with jQuery versions until I discovered that this bug doesn’t occur when using jQuery 1.8.0. I could simply use jQuery 1.8.0 for all browsers, but that didn’t sit well with me. I want to use the most up to date working version of jQuery possible for each browser. That meant using 1.11.1 for Internet Explorer and 1.8.0 for all other browsers. I accomplished this by using conditional comments to reference my jQuery scripts. Figure 2 shows the original code that I had to reference jQuery script. Figure 3 shows the code containing conditional comments that I replaced it with.Figure 2
In Figure 3 the first line tests to see if our browser is Internet Explorer. If it is, then we import the jQuery library 1.11.1 from Google’s API library. The second line in Figure 3 says that if our browser is not Internet Explorer, then we import the jQuery library version 1.8.0 from Google’s API library. The result of these conditional comments is that we use a working version of jQuery based on the browser we are using.