gpt4 book ai didi

javascript - Google +1 按钮脚本未加载到本地 html 文件中

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:21:31 27 4
gpt4 key购买 nike

我正在尝试使用新的 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>

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

这是我的 Firebug 网络面板的屏幕截图:

screenshot

有人知道为什么会这样吗?

最佳答案

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

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

关于javascript - Google +1 按钮脚本未加载到本地 html 文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7002864/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com