Question

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!

Était-ce utile?

La solution

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>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top