1

我只是在创建一个 html 文件来测试 google +1 按钮。我猜我的html没有部署在服务器上的问题。如何在本地计算机上测试 google+1 按钮。此代码不呈现任何内容。

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Google+1</title>

<!-- <link rel="stylesheet" href="css/main.css" type="text/css" /> -->
<script type=”text/javascript” src=”http://apis.google.com/js/plusone.js”&gt;</script>
</head>

<body >

<g:plusone></g:plusone>


</body>
</html>
4

2 回答 2

1

我认为它无法完成,因为谷歌的 API 检查请求的来源,否则会存在许多安全漏洞。

为什么不上网查呢?只需将网站上传到其域并尝试从您的帐户 +1。

仅用于设计目的的另一个选项:下载 +1 按钮的图像并在离线版本中使用。

于 2013-03-30T16:19:06.957 回答
1

您可能只是在本地打开 HTML 文件。您可以在本地计算机上运行 Google+ 小部件,并且需要能够访问 Internet 才能加载外部脚本。您需要做的是启动 Web 服务器并从那里打开文件。这是由于 +1 代码需要对 JavaScript 的权限。

如果您在 Mac 上,您可以通过内置的 Apache 服务器(将文件复制到 /Library/WebServer/Documents 并导航到 localhost/filename.html)或通过在同一服务器中启动 Python Web 服务器来执行此操作使用以下命令将文件夹作为文件:

python -m SimpleHTTPServer 8000

启动 Python Web 服务器后,您可以导航到 localhost 端口 8000。

If you are running on a Windows PC, you can find a number of web servers and install them, WAMP is a pretty simple option. Again, you would just install WAMP and then put your HTML file in the web/www folder that WAMP created and navigate there from localhost. You can also install Python and use the built-in web server as mentioned before.

于 2013-03-30T16:50:11.893 回答