But Is jQuery Already Loaded?

JQuery

JQuery (Photo credit: Wikipedia)

Many end users are taking advantage of all of the goodness that jQuery provides, whether by adding simple effects like a sliding Quick Launch, more sophisticated form enhancements like SPCascadeDropdowns from SPServices, or even writing their own scripts for more complex solutions. More than ever, the distinction between “end user” and “developer” is blurring. IMO, that’s a good thing, but it also introduces complications, of course.

As one of those end users, you owe it to yourself to talk to your SharePoint team to explain what you are doing and to find out if jQuery is already loaded in the environment. In many cases, it will already be loaded in the master page or a page layout so that it is readily available across the Site Collection. The version that is loaded can also have an impact on how plugins function, making some of them effectively useless if there’s a version mismatch.

I know that in some cases, even finding the person who might know what’s loaded in the master page or what the plans may be is well nigh impossible. In those cases, here’s a trick to find out what’s up.

In a Internet Explorer browser window with the page you want to work with open, hit F12 to open the Developer Tools, and go to the Console. The screenshot below is from IE9, where there is a separate Console tab:

SNAGHTML562e339

If you’re in IE8, the Console is hidden under the Script tab, as below.

SNAGHTML5632086

If you’re in an older version of IE, well, I don’t have a screenshot for you. You may also not have the Developer Tools available, as it was a separate download with IE7 and below.

In Firefox, you’ll need the firebug add-in. If you have it, you can hit F12 to open Firebug. The Console tab is the first one on the left:

SNAGHTML56920f4

Once you’ve gotten to the Console, wherever it is, type the line I show in each of the screenshots above:

jQuery.fn.jquery

Depending on where you are, you’ll then either hit enter or click on the Run button.

Somewhere on the screen, you’ll see a display like this one, which shows that jQuery version 1.7.1 is loaded…

SNAGHTML56b32de

…or you’ll see something like…

SNAGHTML56d0846

…which tells you that jQuery isn’t loaded at all.

At that point, at least you’ll know what you are dealing with. If the version number isn’t what you need (I sometimes still see jQuery 1.3.2 loaded in a master page, which is ancient) then you’ll need to talk to your SharePoint team about updating it.

Tip ‘o the skimmer to Matt Bramer (@ionline247) for the exact syntax…

https://twitter.com/#!/iOnline247/status/200574868524236800

…and @BinaryJam for asking the question in the first place!

https://twitter.com/#!/BinaryJam/status/200566890437951488

Enhanced by Zemanta

"Please Upgrade Your Browser to IE8 or Above": But I’m Already Running IE8!

This one is from way off in left field, but it explains many oddities that I’ve seen over the last 6 or more months, I think. Stick with me as I explain it. There are some goodies along the way, as well as the solution to this problem. At the very least, I get to gratuitously stick a bunch of cool images and logos into a pretty long post.

imageYesterday I saw a tweet from my good friends over at TripIt (if you travel, even only occasionally, you *must* try TripIt!) about all the cool sites that are now integrating with them. One imageof those, called Tripline, caught my eye. An article at TripIt’s blog called How Many Third Party Apps Have You Synced with TripIt? says:

Easily make sharable, animated trips with photos, music, links, and stories.  Once you connect your Tripline account with TripIt, you can import your TripIt trips into Tripline, which will automatically create a travel map for this trip, equipped with travel dates and places. It’s a great way to share your trips with friends, or relive them later.

To get started, create your free Tripline account, then connect your TripIt account on their settings page.

imageWimageell, yeah, that sounded awesome. So I signed up immediately using the browser on my iPhone from my couch. Of course, that experience left a little to be desired, so today I went to load up Tripline on my laptop, and the site told me that I had an unsupported browser and I should upgrade to IE8.

Now wait a cotton-pickin’ minute! I am running IE8!

imageCome to think of it, Microsoft’s sites have told me I should upgrade my browser for months, too, and way before IE9 was in beta. (See, this goes back a while.) Proud Microsoft supporter that I am, I assumed that they had a bug in their browser detection and kept ignoring it.

Well, this really annoyed me, so I turned to Twitter for help, and my pals Matt Bramer (@IOnline247) and Brian T Jackett (@BrianTJackett) suggested turning off add-ons and checking the Compatibility Mode, respectively. Nope and nope. However, since I had imageChrome installed and WhatIsMyBrowser.com told me that I was running Chrome, which was claiming to be IE8 (this was a red herring), I uninstalled Chrome, imageGoogle Gears, and imageChrome Frame. Still no dice. At least WhatIsMyBrowser.com was telling me at that point that I was running IE8, but on Windows XP!image I have been running imageWindows 7 since the beta, thank you very much! (FWIW, I like Chrome, but even though Matt keeps telling me to switch to it completely, my clients mainly use IE, and so I mainly use IE. Besides, I’ve used IE since imageversion 1.0. Why switch?)

Where the heck is this going, you might ask? Well, stay with me.

Since Tripline seemed really intriguing, and this whole “you’re running an old browser” thing was now truly pissing me off, I decided to email Tripline to see if they could tell me why they wanted to upgrade my already fairly fresh browser. Here, I probably owe the Tripline folks an apology, since I had an inkling that it wasn’t a problem on their end, but I really didn’t know.

Well, it was Byron at Tripline HQ to the rescue, I’ll tell you. Unlike many support experiences (don’t get me started), this one was A#1 top notch. I got an email back almost immediately, and Byron really wanted to figure this one out.

Byron suggested the Compatibility View angle (as we already know, that was a dead end), but in his next email, he asked me to check what my browser was reporting in its User Agent string by typing

javascript:alert(navigator.userAgent)

into the address bar. (See this MSDN article for details on what this does.)image

Now we were getting somewhere. Here’s what I got:

SNAGHTML112c7b7

imageByron saw what was going on right away (highlighted above). My browser was reporting that it was IE8 just fine, but it was also reporting that it was IE6! Byron pointed me to this article which, way down at the bottom, suggests what might be happening and how to fix it. (I’ve taken the liberty to copy that section of the article below. Thanks to Eric Lawrence and his EnhanceIE site.)

I found the offending User Agent string in the

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\User Agent\Post Platform

key and just for completeness, I searched the registry for other occurrences of “MSIE 6.0” and found the following:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows Search\Gathering Manager

image

I left that one alone, but interesting, eh?

So, I deleted the offending value in the

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\User Agent\Post Platform

key, rebooted, and wah-la: I’m running IE8 again!

Here’s my nice, clean User Agent string, and now I’m even running the 64 bit version of Windows 7 when I go to WhatIsMyBrowser.com.

SNAGHTML31bfb6

 

Whew.

Thanks again to Byron at Tripline. Check out their stuff. It looks totally awesome. Especially in IE8.

 

Solution from the Eric Lawrence at his EnhanceIE site

Problem: Nested UA String

In this case, the User-Agent string is corrupted, with two instances of the Mozilla/4.0 token. This typically is caused by a bad registry key. Problems of this nature are caused by poorly written addons or utilities that write incorrect values to the registry.

GET / HTTP/1.1
Accept-Language: en-us
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 3.5.30729; InfoPath.2)
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Host: 192.168.10.1

As you can see in the example above, an IE6 user-agent string is written in the middle of the IE8 user-agent string. This bad string is dynamically generated out of a registry key. By removing the registry key, you can fix the problem.

To fix this, click START > RUN > REGEDIT.EXE. Using RegEdit, navigate to these four keys:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\User Agent\Post Platform
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\User Agent\Post Platform
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\User Agent\Post Platform
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Internet Settings\User Agent\Post Platform

…and remove any elements from the “Name/Type/Value” list that contain Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ;

For 64 bit computers, also check:

HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\User Agent\Post Platform

Script Error When Editing a Content Editor Web Part (CEWP) in IE8

I’m not a big fan of clunky workarounds, but they do have their place in the world.

This one occurred with a SharePoint 2007 site and IE8. Now I know that by default, this should work fine, but I’m not the first person to run across this issue.

It may happen that if you are running IE8, add a Content Editor Web Part (CEWP) to a page, open the Tool Pane and click on the Rich Text Editor button to edit it, you’ll get a script error. The error will look something like this:

Message: Invalid argument.
Line: 5739
Char: 2
Code: 0
URI: http://[YourWebApplication]/_layouts/1033/HtmlEditor.js

The workaround is to go into Compatibility View. Once the page refreshes in that view, things will function as expected. I don’t know why, and it doesn’t fix the problem, but you can get your work done.  It’ll satisfy my user until we upgrade to SharePoint 2010.

This IE8 Popup Drives Me Nuts: “Do you want to view only the webpage content that was delivered securely?”

image

I’ve fixed it on multiple machines, but I always forget where the setting is.  Here, for future me when he needs them, are the simple steps to make this annoying popup go away:

  1. Go to Tools->Internet Options->Security
  2. Select the ‘Security’ tab
  3. Click the ‘Custom Level’ button
  4. In the ‘Miscellaneous’ section change ‘Display mixed content’ to Enable

Thanks to this article at HTTPWatch: Fixing the IE 8 warning – ‘Do you want to view only the webpage content that was delivered securely?’

Why are My Cookies Being Deleted in IE8?

Ever since I upgraded from IE7 to IE8 (first to the beta, then to the released version), I’ve seen that my cookies seem to disappear from time to time.  This is evidenced by the fact that I need to log in again to such innocuous sites as my.yahoo.com.  I’ve finally figured out that this seems to be happening every time I reboot my machine (or it decides to crash upon waking up from hibernation – this happens all the time.  ARGH.)  Sometimes it takes a while to see patterns in these things.  Or I just ignore it until it bugs me enough to do something about it.

In searching for a solution, I’ve seen that a lot of folks are having problems with IE8 and CCleaner with respect to cookies, but I’m not running CCleaner.  Some other posts led me to look at the Delete Browsing History screen below.  You can get to this either from Tools / Internet Options / Browsing History / Delete or from Safety / Delete Browsing History…

imageAs I understand it, having Preserve Favorites website data checked means that content belonging to sites in your Favorites will preserve their cookies and temporary Internet files.  But I rarely use Favorites (sort of a perverse laziness).  Now I really like cookies.  I don’t really worry too much about my privacy at this level and I don’t *want* to have to retype my usernames and set other settings all the time.

Unfortunately this screen is an *active* delete of browsing history, so I don’t think that changing anything will have an effect.  I’m not the only one complaining about this out on the ‘Net, so hopefully there’s a solution out there somewhere.  Let me know if you find it!

I’ve posted this question to the MSDN Internet Explorer Web Development Forum but so far, no responses.