Javascript 添加Google plus+;1按钮和IE8问题

Javascript 添加Google plus+;1按钮和IE8问题,javascript,jquery,html,css,google-plus-one,Javascript,Jquery,Html,Css,Google Plus One,有没有办法通过js动态添加Google plus+1按钮?我需要它,因为一个页面有许多URL要共享,它们是通过AJAX获得的。所以,当我得到需要的URL时,我想在页面的某些地方生成“+1”-s 我编写的测试代码适用于除IE8之外的所有浏览器(谷歌根本不支持IE7): jQuery(函数(){ jQuery('.googlePlusBtn').html(''); jQuery('a.addGooglePlus')。单击(函数() { var po=document.createElement

有没有办法通过js动态添加Google plus+1按钮?我需要它,因为一个页面有许多URL要共享,它们是通过AJAX获得的。所以,当我得到需要的URL时,我想在页面的某些地方生成“+1”-s

我编写的测试代码适用于除IE8之外的所有浏览器(谷歌根本不支持IE7):



jQuery(函数(){
jQuery('.googlePlusBtn').html('');
jQuery('a.addGooglePlus')。单击(函数()
{
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);
返回false;
})
})
你能帮帮我吗

UPD:已修复。解决方案如下:



jQuery(函数(){
var po=document.createElement('g:plusone');
var s=document.getElementById('googlePlusBtn');
s、 儿童(po);
jQuery('a.addGooglePlus')。单击(函数()
{
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);
返回false;
})
})
所以,刚刚将createdocument方法从jQuery更改为CleanJavaScript。IE8与此配合使用

解决方案如下:



jQuery(函数(){
var po=document.createElement('g:plusone');
var s=document.getElementById('googlePlusBtn');
s、 儿童(po);
jQuery('a.addGooglePlus')。单击(函数()
{
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);
返回false;
})
})

所以,刚刚将createdocument方法从jQuery更改为CleanJavaScript。IE8与此配合使用

您应该将您的修复作为答案发布,以便将其标记为正确答案。这会把你的问题从没有答案的名单中拉出来。谢谢!我不知道。。。完成。您也可以接受自己的答案(-: