I've been using gravatar hovercard code on my site.
I noticed I get an error in IE with certain themes, 2010 weaver is one, for example.
“Object doesn’t support this property or method line 331 char 3.” is the error.
It works fine with twenty ten and on wordpress.com and webtoolscollection. I’m guessing it has something to do with java script conflicts, I’m totally lost in that area.
http://ottopress.com/2010/gravatar-hovercards/ is the code I'm using.
http://test.zeaks.org Is where I'm using it, no other plugins except for the recent comments are installed.
Any help is appreciated.
Can you post the file that you're using the code in on the pastebin, or are you using it as a plugin?
Here it is in pastebin.
http://wordpress.pastebin.com/JXhMyeeu
I've also tried just using this in functions.php and had the same issue as with the plugin.
http://wordpress.pastebin.com/dqee8Um5
Try instead (an older version of Otto's code):
<?php
/*
Plugin Name: Gravatar Hovercards
*/
function gravatar_hovercards_jquery() {
wp_enqueue_script('jquery');
}
add_action('wp_enqueue_scripts', 'gravatar_hovercards_jquery');
function gravatar_hovercards() {
echo '<script type="text/javascript" src="http://s.gravatar.com/js/gprofiles.js"></script>';
}
add_action('wp_footer','gravatar_hovercards');
?>
Still causes the same error >.<
Can you paste the source output of your page when it's finished load to the pastebin? I'm curious about what line 331 char 3 is.
Sure, but what file do you want me to paste from? I'm using the plugin.
Activate one of the themes that's giving you trouble and load http://test.zeaks.org/
Then, view the source. In Chrome, that's View/Developer/View Source, and in Firefox it's View/Page Source.
Now, copy that into the pastebin.
Also, let us know which line and character the error references this time.
Line 331 is font-size: 1.2em; which would mean that char 3 is n, which really doesn't seem like a problem to me.
And everything is fine when you remove the hovercard code?
yes everything is fine once I turn it off, no IE errors.
yes, I've tried ie 9 before and it does the same thing for me
Ok, try just this:
<?php
/*
Plugin Name: Gravatar Hovercards
*/
function gravatar_hovercards() {
echo '<script type="text/javascript" src="http://s.gravatar.com/js/gprofiles.js"></script>';
}
add_action('wp_footer','gravatar_hovercards');
?>
Still get an error in IE line 862 char 1, but it doesn't work at all in FF with that code.
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0)
Timestamp: Thu, 14 Oct 2010 06:25:51 UTC
Message: Object expected
Line: 862
Char: 1
Code: 0
URI: http://s.gravatar.com/js/gprofiles.js
That's probably because your theme doesn't enqueue jquery, so you'll need the first half of that code. One more thing to try:
<?php
/*
Plugin Name: Gravatar Hovercards
*/
function gravatar_hovercards_jquery() {
wp_enqueue_script('jquery');
}
add_action('wp_enqueue_scripts', 'gravatar_hovercards_jquery');
function gravatar_hovercards() {
echo '<script type="text/javascript" src="http://s.gravatar.com/js/gprofiles.js?g"></script>';
}
add_action('wp_footer','gravatar_hovercards');
?>
(note the slightly different script URL)
Still get an error with that one in IE, works in FF fine though.
Message: Object doesn't support this property or method
Line: 335
Char: 3
Code: 0
URI: http://s.gravatar.com/js/gprofiles.js?g
Appreciate the help btw
Oh, it's getting the error from the js file!
Well, line 335 is description = GProfile.get( 'aboutMe' ); which makes char 3 s, which still doesn't help. :(
I'm going to call for backup on this one. Hang tight.
FYI, I just dug out my PC and checked my blog in IE 8, same problem. So, I checked Otto's site, same problem there too. Then, I checked wordpress.com, no problem there. At least you aren't alone, but there's definitely something they're doing differently on wordpress.com.
I see the error on these forums in IE as well, but yeah wordpress.com blogs are fine, same with some themes. if I switch to twenty ten it works fine.
I don't know why, but I do know that my hovercard doesn't load properly. Bah.
mrmist, you have to use your gravatar account's primary email address. It's a limitation in the profile API.
bah, that defeats the purpose of having multiple addresses bound to it.
Yeah, apparently the majority use their different gravatars as different personas or identities, so having them all link back to the same profile would defeat that purpose. Fortunately, the Gravatar crew is working on an opt-in feature.
Multiple identiies? Good gosh. I have enough trouble with one.
On the .org forums, it seems like the issue is that jQuery isn't being loaded in IE for some reason. Check out "View Source" for this page in IE and it's missing the script tag for jQuery.
Okay, figured it out. Turns out IE is flailing because of a global and local variable conflict. and the culprit is the description variable.
Add this code to the your head or right before you echo the gravatar script:
<script type="text/javascript">var description = '';</script>
I tested through IE's developer tools and that seems to fix the problem.
jQuery isn't loading here on .org unless you're logged in. Dunno why, but I'll sort it out.
The description fix did work for me on ottopress.com. No idea why.
And for those who care to know what the specific issue is:
When you add a meta description tag on your page, i.e. <meta name="description" content="..." IE adds a global JavaScript variable called description, that returns the meta tag.
One of the gravatar functions is using a description variable but not defining it as local scope. So IE thinks it should use the glboally defined description var. But IE apparently doesn't like converting objects to strings, which is why it's throwing the error.
Thanks everyone, works now