WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Hovercards on self hosted theme issue (32 posts)

  1. zeaks
    Member
    Posted 3 years ago #

    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.

  2. Can you post the file that you're using the code in on the pastebin, or are you using it as a plugin?

  3. zeaks
    Member
    Posted 3 years ago #

    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

  4. 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');
    
    ?>
  5. zeaks
    Member
    Posted 3 years ago #

    Still causes the same error >.<

  6. 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.

  7. zeaks
    Member
    Posted 3 years ago #

    Sure, but what file do you want me to paste from? I'm using the plugin.

  8. 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.

  9. zeaks
    Member
    Posted 3 years ago #

    ok, here it is http://wordpress.pastebin.com/yATtPNV0

    331 character 3

  10. 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?

  11. zeaks
    Member
    Posted 3 years ago #

    yes everything is fine once I turn it off, no IE errors.

  12. Are you using IE 8?

  13. zeaks
    Member
    Posted 3 years ago #

    yes, I've tried ie 9 before and it does the same thing for me

  14. 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');
    
    ?>
  15. zeaks
    Member
    Posted 3 years ago #

    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

  16. 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)

  17. zeaks
    Member
    Posted 3 years ago #

    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

  18. 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.

  19. 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.

  20. zeaks
    Member
    Posted 3 years ago #

    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.

  21. mrmist
    Forum Janitor
    Posted 3 years ago #

    I don't know why, but I do know that my hovercard doesn't load properly. Bah.

  22. mrmist, you have to use your gravatar account's primary email address. It's a limitation in the profile API.

  23. mrmist
    Forum Janitor
    Posted 3 years ago #

    bah, that defeats the purpose of having multiple addresses bound to it.

  24. 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.

  25. mrmist
    Forum Janitor
    Posted 3 years ago #

    Multiple identiies? Good gosh. I have enough trouble with one.

  26. Mohammad Jangda
    Member
    Posted 3 years ago #

    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.

  27. Mohammad Jangda
    Member
    Posted 3 years ago #

    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.

  28. Samuel Wood (Otto)
    Tech Ninja
    Posted 3 years ago #

    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.

  29. Mohammad Jangda
    Member
    Posted 3 years ago #

    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.

  30. zeaks
    Member
    Posted 3 years ago #

    Thanks everyone, works now

Topic Closed

This topic has been closed to new replies.

About this Topic