specify custom url to gplus one button

♀尐吖头ヾ 提交于 2019-12-11 19:09:07

问题


I have this code

<div class="google_button">
   <g:plusone size="medium" annotation="none"></g:plusone>
   <% case I18n.locale.to_s %>
   <% when 'en' %>
    <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>
    <% when 'es'%>
     <script type="text/javascript">
      window.___gcfg = {lang: 'es'};
      (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>
   <% end %>
  </div>

I have in a variable url a url:

url = "http://www.mydomain.com/my_custom_url"

I want add to this google plus button this url variable.

How can I do it?

Thank you very much!


回答1:


I managed to find the developer docs. It's a little confusing, but you just need to put the URL as the href attribute of the <g:plusone> tag. For instance:

<g:plusone size="medium" annotation="none" href="the url!"></g:plusone>


来源:https://stackoverflow.com/questions/13297837/specify-custom-url-to-gplus-one-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!