我试图创建一个按钮来分享google plus的链接。
按照指示创建共享按钮并且运行良好非常好。但是,当动态创建时,按钮不起作用?
这是我的代码示例:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
(function () {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/client:plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
function load() {
var link = "http://www.tuoitre.vn";
var googlePlus = "";
googlePlus += "<button class='g-interactivepost' style='cursor:pointer;text-decoration: none;'";
googlePlus += "data-contenturl='" + link + "'";
googlePlus += "data-clientid='149537423034-t67d58e6lhmrm89g0puh6rqftk940r83.apps.googleusercontent.com";
googlePlus += "data-cookiepolicy='single_host_origin'";
googlePlus += "data-prefilltext=''";
googlePlus += "data-calltoactionlabel='OPEN'";
googlePlus += " data-calltoactionurl='" + link + "'>";
googlePlus += "Share</button>";
document.getElementById("postshare").innerHTML = googlePlus;
}
</script>
</head>
<body onload="load();">
<div id="postshare">
</div>
</body>
</html>