Using Google +1 service without JavaScript
Asked Answered
N

4

8

I would like to add a Google +1 icon to a website, but without using JavaScript. Is it possible? Is there some URL I can simply link to, to make it work?

Northumberland answered 28/8, 2011 at 2:10 Comment(0)
N
10

Google now supports sharing via a static URL:

https://plus.google.com/share?url=URLHERE

More information there: https://developers.google.com/+/plugins/share/#sharelink

Northumberland answered 10/8, 2012 at 8:47 Comment(0)
U
4

There is a feature request you can comment on to show your support: https://code.google.com/p/google-plus-platform/issues/detail?id=50

In the meantime, since there is no +1 button fallback when javascript is disabled, Google feels that tracking users is more important than not having people be able to share stuff via their service.

Either use Edy Freddy's nice hack to alleviate the privacy concerns, or take your cue from the +1 fallback to nothing when javascript is disabled. Skip implementing Google+ until they implement this. -Steve

Uzziel answered 15/11, 2011 at 15:26 Comment(0)
T
2

I don't think so. The part behind delivered by Google is some JavaScript. Maybe you can analyze the JavaScript and extract something like a link from it, but they wouldn't promote, because they would loose the opportunity to track the users of the websites with +1 buttons on. Another reason why there might be no solution without JavaScript is, that the special functionalities bound to the session of logged in Google users will get lost.

But I have a nice solution for you that I found a few days ago on the web. It helps the visitors of your website to keep their privacy and not to be tracked by Google in an unwanted way, when you put the +1 button on your website.

Put the button of your choice on your own domain and implement this alternative JavaScript. It loads the JavaScript from Google only when the users click the +1 button.

Implement the Google +1 button data privacy safe

<script type="text/javascript">
    function loadScript(jssource) {
        var jsnode = document.createElement('script');
        jsnode.setAttribute('type','text/javascript');
        jsnode.setAttribute('src',jssource);
        document.getElementsByTagName('head')[0].appendChild(jsnode);
        document.getElementById('plus1').innerHTML = "";
    }
    var plus1source = "https://apis.google.com/js/plusone.js";
</script>

<a id="plus1" href="javascript:loadScript(plus1source)">
<img width="76" height="24" title="Show Google +1 Button" alt="Show Google +1 Button" src="http://www.yourwebsite.tld/showplusone-2.jpg">
</a>
<g:plusone></g:plusone>
Temporize answered 28/8, 2011 at 2:36 Comment(0)
R
1

Eddy Freddy's answer is an elegant trick, but it doesn't address the question asked.

In some places you just can't have JavaScript no matter how hard you wish for it! Same goes for iFrames and CSS in some cases too. "Where would this happen?", you might well ask; Easy answer: email clients.

It's workable to make a simple static link to post to twitter. Before it actually posts the tweet, you're landed on a page where you're given the opportunity to edit and approve the message as a logged in user first, so what we're looking for is a Google +1 equivalent of this functionality.

It would not be unreasonable to implement this yourself. Add a +1 static link to a page of your own creation that is in an environment where you can run JS etc, and thus the user can be a logged in google user at the time, at which point a second click can confirm the post. This approach only really applies to email clients though - if you're blocked for other reasons (e.g. some security policy that bans JS everywhere), you're still stuffed.

Pretty much the same thing applies to Facebook Like buttons as they behave the same way and impose the same requirements. Twitter seems to be the only site that's thought about this and provides an official JS-free mechanism.

There's no way around the two-click requirement as without it anyone would be able to post as anyone else, which would be silly.

Radley answered 2/10, 2011 at 21:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.