我在同一个 WordPress 页面中有 3 个 google +1 按钮。但其中一个在单击时失败(在 float 横向小部件中),显示感叹号。
再次单击时,将打开以下页面: +1 button is unavailable or has stopped working.我非常确定所描述的可能原因都不会发生。
两者的代码实际上是相同的:
// float code (malfunction)
<div id="float_plusone">
<g:plusone size="tall" href="<?php echo urlencode(get_permalink()); ?>" count="true"></g:plusone>
</div>
<script type="text/javascript">
(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>
// above/below posts code (works)
<script type="text/javascript">
(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>
<g:plusone size="medium" callback="googleplus_click"></g:plusone>
非常欢迎任何建议。
最佳答案
这是按钮发送到服务器以 +1 的 URL。
"id":"http://bestpushchairs.net/qc21/disclosure-policy/http%3A%2F%2Fbestpushchairs.net%2Fqc21%2Fdisclosure-policy%2F"
看起来按钮正在获取 href
值并假设它相对于当前路径。尝试不使用urlencode
。
关于javascript - +1 按钮不可用或已停止工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9828494/