在IE 8中加载页面后添加Google +1按钮 [英] Adding a Google +1 Button after page load in IE 8

查看:95
本文介绍了在IE 8中加载页面后添加Google +1按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在网站上工作,我需要在将按钮放在页面上之前构建URL。以下是它的工作原理:

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();

在头脑中我有这个:

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

这适用于Firefox / Chrome / IE 9,但不适用于IE 8.我很茫然至于还有什么办法让它发挥作用。我也试过了gapi.plusone.render()方法,但仍然没有运气。

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.

推荐答案

这是解决方案,它在IE7 / 8中适用于我:

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);

似乎使用innerHTML插入< g:plusone>< ; / g:plusone> 元素进入页面在IE7 / 8中不起作用,直接创建g:plusone元素: document.createElement('g:plusone' )。
查看更多: http://www.google.com/support/forum/p/Webmasters/thread?tid=3d63228b915dab32

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

这篇关于在IE 8中加载页面后添加Google +1按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆