Google+ Share

Google+ Share

Google+ Share buttons

Google+ Share buttons (Google +分享按钮)

All of us know what Google is and how much we need it. Every Developer needs Google. As you see, Google+ is a very useful and beautiful thing. In many-many websites, there are Google+ share buttons, and these buttons can be very different. Let’s see what kind of Share/Post buttons Google has and how you can use it. Let’s see the first kind of button. (我们都知道谷歌是什么,以及我们有多么需要它。每个开发者都需要谷歌。如你所见, Google +是一个非常有用和美丽的东西。在许多网站中,都有Google +共享按钮,这些按钮可能会有很大不同。让我们来看看谷歌有哪些分享/发布按钮,以及如何使用它。让我们来看看第一种按钮。)

Please note that Google + Share is not active anymore. (>请注意, Google +共享不再有效。)

Google+ Simple Share

Google+ Simple Share (Google +简单分享)

To use a share button in a simple way you must connect a script to your page. Here it is. (要以简单的方式使用共享按钮,您必须将脚本连接到页面。在这里。)

<script src="https://apis.google.com/js/platform.js" async defer></script>

This tag is necessary for sharing anything from your website. The script must be sourced at https and can be included at any point on the page without restriction. So when we connect that script, what is the next step? The next step is the share button tag. (此标签对于分享您网站上的任何内容是必需的。脚本必须源自https ,并且可以不受限制地包含在页面的任何位置。因此,当我们连接该脚本时,下一步是什么?下一步是共享按钮标记。)

Here it is. (它在这儿。)

<g:plus action="share" ...></g:plus>                 <!-- HTML -->
<div class="g-plus" data-action="share" ... ></div>  <!-- HTML5 -->
<!DOCTYPE html>
<html>
 <head>
   <title>www.w3cdoc.com</title>
   <link rel="canonical" href="//www.w3cdoc.com/" />
   <script src="https://apis.google.com/js/platform.js" async defer></script>
 </head>
 <body>
   <g:plus action="share"></g:plus>
 </body>
</html>

The Google+ Share gets all properties (URL, description, image, website etc..) from you webpage meta (link/canonical) tags. You need to have meta tags for all those properties if you want to have a custom property in your share block. (Google +共享从您的网页元(链接/规范)标签中获取所有属性( URL、描述、图像、网站等)。如果要在共享块中拥有自定义属性,则需要为所有这些属性设置元标记。)

Google+ Share a Link (Google+ 分享链接)

Here is another kind of share a page. It’s the easiest way to have a share button on your webpage. This kind of share can be handy because it’s straightforward, simple and has shortcode. (这是另一种分享页面的方式。这是在网页上设置分享按钮的最简单方法。这种共享很方便,因为它简单明了,而且有短代码。)

<!DOCTYPE html>
<html>
 <head>
   <meta charset="utf-8"/>
   <title>w3cdoc share</title>
 </head>
 <body>
   <a href="https://plus.google.com/share?url=//www.w3cdoc.com/learn-javascript/google-share.html" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,height=600,width=600');return false;"><img
 src="https://www.gstatic.com/images/icons/gplus-64.png" alt="Share on Google+"/></a>
 </body>
</html>

This type of share button has image three sizes by default. You can use whatever size you want or change the image and set your custom. (默认情况下,此类共享按钮具有三种尺寸的图像。您可以使用任何您想要的尺寸,也可以更改图像并设置自定义尺寸。)

SizeExampleImage URLWidthHeight
Largehttps://www.gstatic.com/images/icons/gplus-64.png6464
Mediumhttps://www.gstatic.com/images/icons/gplus-32.png3232
Smallhttps://www.gstatic.com/images/icons/gplus-16.png1616

Google+ Share has many APIs, and an API has many properties and functions.



请遵守《互联网环境法规》文明发言,欢迎讨论问题
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部