4

I'm working on a site right now where I need to build a URL before putting the button on the page. Here's how it works:

var googleplus = $("<g:plusone size='tall' href='http://google.com'></g:plusone>");
$("#container").append(googleplus);
gapi.plusone.go();

And in the head I have this:

<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>

This works in Firefox/Chrome/IE 9, but not IE 8. I'm at a loss as to what else to do to make it work. I tried with the gapi.plusone.render() method as well, still no luck.

John Conde
  • 217,595
  • 99
  • 455
  • 496
Eric Roberts
  • 285
  • 2
  • 11

1 Answers1

4

Here is the solution, it works for me in both IE7/8:

var gPlusOne = document.createElement('g:plusone');
gPlusOne.setAttribute("size", "tall");
gPlusOne.setAttribute("href", "http://google.com");
container.appendChild(gPlusOne);

it appears that using innerHTML to insert a <g:plusone></g:plusone> element into a page does not work in IE7/8, Create the g:plusone element directly like this: document.createElement('g:plusone'). see more: http://www.google.com/support/forum/p/Webmasters/thread?tid=3d63228b915dab32

Andy Wan
  • 1,090
  • 2
  • 11
  • 23
  • While this helped out a specific version of IE8 (v 8.0.7600.16385), it did not help IE7. At least I'm one step closer to the holy grail. FWIW, it looks like there issues with IE7 as well as Google says they don't support IE7 (see http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=1151309) – DMCS Nov 21 '11 at 23:43