4

我正在使用新的 Google +1 按钮,并尝试设置一个简单的演示。

这是我的代码:

<html>
<head>
<title>Plus One</title>
</head>
<body>

<!-- Place this tag where you want the +1 button to render -->
<g:plusone callback="plus_one_callback" href="http://www.testurl.com/"></g:plusone>

<!--  Place this tag after the last plusone tag -->
<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);
  })();

function plus_one_callback(){
    alert('callback');
}
</script>


</body>
</html>

但是它不会呈现按钮,并且我的控制台中没有错误消息。

这是我的萤火虫网络面板的屏幕截图:

截屏

有谁知道为什么会这样?

4

1 回答 1

2

它不起作用,因为从 Firefox 3 开始,您无法在本地运行外部 JS 脚本。或者更准确地说,当 Firefox 在 url 中看到“file://”时,您会遇到问题。这个问题也在这里得到了回答。如果您使用其他浏览器,它可能会起作用。

但是,如果您真的需要这种东西在本地工作,那么有一个解决方案。您可以安装WAMPXAMPP来运行本地服务器。

于 2011-09-15T21:21:56.543 回答