Compatibility with IE8

Dec 30, 2011 at 5:19 PM

I recently used this library on a project and encountered a problem with IE9 set to work in IE8 document mode. A portion of the code I used is below:

<script src="../style%20library/scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="../style%20library/scripts/jquery.SPServices-0.7.0.min.js" type="text/javascript"></script>

<script type="text/javascript">
$(document).ready(function() {
$('nobr:contains("SecurityKey")').closest('tr').hide();
$('nobr:contains("Email")').closest('tr').hide();
$('nobr:contains("Name of person other than Joe.")').closest('tr').hide();
$('nobr:contains("Firstname")').closest('tr').hide();
var userName = $().SPServices.SPGetCurrentUser({fieldName: 'Title'});
var userEmail = $().SPServices.SPGetCurrentUser({fieldName: 'EMail'});
$("input[Title='Firstname']").val(userName);
$("input[Title='Email']").val(userEmail);

When I used the developer tool with IE9 and reached the variables for userName and userEmail, both were blank. I then tried Chrome (16.0) and both values displayed correctly. I changed the compatibility mode with IE9 to IE9 and both values were found and entered correctly. I then located an IE8 browser and verified that the values were not selected. For the record, the debugger showed the values going from undefined to an empty string. I tested this result in several different environments on two other networks. I also tested IE7 and it appears that only IE9 Document mode works. Is there something I am missing?

Coordinator
Dec 30, 2011 at 5:35 PM

I can't seem to reproduce this. I've tried setting IE9 to IE8 more and IE7 mode, and I still get the results I expect. Is it possible that you have another error in your script you haven't caught?

M.

Dec 30, 2011 at 5:40 PM
Just a hunch...
Check the page's <!DOCTYPE> and report back on what it is set to (and that it appears at the top of the HTML)...

I recently uncovered some issues with jQuery and how it behaves in "quirks mode" with newer browsers. Note that in my case, it had nothing to do with SPServices.

Marc,
I think the utility he's trying to use scrapes a page... it may be good to also check the <!DOCUMENT> tag on that one (although, I have a feeling you .load() it via jQuery... if that is the case, then no need).

Paul

Coordinator
Dec 30, 2011 at 6:04 PM

Yup, it's a simple jQuery .ajax() call to grab userdisp.aspx, and I parse the values from it.

M.

Dec 30, 2011 at 6:30 PM

I checked the <!DOCTYPE> and it is reads:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

There is no tag for <!document> that I find.

Les

Dec 30, 2011 at 6:35 PM
Les,
I meant DOCTYPE... Sorry about the confusion.
_____
Paul

Sent from mobile device.

Dec 30, 2011 at 7:06 PM

Paul,

No problem. I am currently prepping a test environment to strip the code down to the basic function and determine the results. I will post back when completed. Thanks for your input.

Dec 30, 2011 at 8:05 PM

Les,

On closer look... is that the complete <!DOCTYPE>?  or did you miss the closing '>' at the end.

I just checked my notes on a problem I was having with jQuery's UI .dialog()... In this thread, I found the resolution that asked for the <!DOCTYPE> to be set correctly... So for you, it should be:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
See if perhaps this solves your problem... Here is more info. on <!DOCTYPE>:

http://en.wikipedia.org/wiki/Quirks_mode#Comparison_of_document_types

 

Paul.

 

Dec 30, 2011 at 8:24 PM

Very strange. In my test environment, it immediately picks up the name and email as I wanted in all browsers. Not only does it work locally, but my test environment is joined to the network and I could retrieve the information from other browsers on other desktops. However, when I applied this stripped down version to the production environment, I encountered the same problem...empty strings. The only way it picked up the correct values was to used F12 and set the browser to IE9 document. I checked that my test environments DOCTYPE was found it to be the same as production.

Thanks for your help in this.

Coordinator
Dec 30, 2011 at 8:29 PM

My guess then is that it may be a network topology or auth issue. Those are the worst to debug, IMO. In IE9's Developer Tools, look at the network traffic and see if you're getting the page back in the .ajax() request. If not, you may see something which might give you a hint as to why not.

M.