Does Google Plus Button API Support Internet Explorer 8

我与影子孤独终老i 提交于 2019-12-11 02:49:33

问题


Does anyone know if the Google Plus Button is supported in IE8? This question suggests that it does not support IE7: Google +1 Button not working in IE7?. Additionally, the question links to a page (http://support.google.com/accounts/bin/answer.py?hl=en&answer=1151309) that suggests that IE8 is supported. Interestingly, when I visit that page in Chrome, I get the G+ button, but when I visit it in IE8, I do not.

Any thoughts?


回答1:


There's one odd-ball version of IE8 (version 8.0.7600.16385 only) that is hard to come by and it causes a rendering error with the Plus1 button rendering. Here's the code you will need to use to get around this issue:

    var gPlusOne = document.createElement('g:plusone'); 
    gPlusOne.setAttribute("size", "medium");
    gPlusOne.setAttribute("annotation", "bubble");
    gPlusOne.setAttribute("width", "120");
    googlePluginDiv[0].appendChild(gPlusOne);

Notice I am not using jQuery as jQuery doesn't like the element named g:plugone, but it can be rendered with document.createElement




回答2:


For me your solution didn't work (on the specified version of ie8...) However, it worked using the HTML5 syntax. I found it here http://chovy.dyndns.org/social2.html.

I reproduce the solution below in case the hosting get down one day :

<div class="g-plusone" data-size="standard" data-count="true" [or data-whatever=...]></div>

I didn't try to load it dynamically using JS, but I guess it should be OK.




回答3:


Works perfectly in IE8 and IE9...but not in IE7
Share Demo: JQuery Iframe

  </head>
  <body>
  <div id="gplusID"></div>

    <script type="text/javascript">
    var gdiv = document.getElementById('gplusID');
    var gPlusOne = document.createElement('g:plusone'); 
    gPlusOne.setAttribute("size", "medium");
    gPlusOne.setAttribute("annotation", "bubble");
    gPlusOne.setAttribute("width", "120");
    gdiv.appendChild(gPlusOne);
      window.___gcfg = {
        lang: 'en-US'
      };

      (function() {
        var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
        po.src = 'https://apis.google.com/js/plusone.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
      })();
    </script>  

  </body>

</html>


来源:https://stackoverflow.com/questions/8902337/does-google-plus-button-api-support-internet-explorer-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!