Google plus one button not showing
Asked Answered
G

4

7

I'm trying to add a Google +1 button to my website.

I have followed the instructions here: http://www.google.com/intl/en/webmasters/+1/button/index.html

This the code for my webpage:

<html> 
    <head> 
        <title>
            Why won't it appear?
        </title>
        <!-- Place this tag in your head or just before your close body tag -->
        <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
    </head> 
    <body> 
        <h1>
            Example title
        </h1>
        <!-- Place this tag where you want the +1 button to render -->
        <g:plusone size="tall" href="http://www.example.com/"></g:plusone>
    </body> 
</html> 

As you can see, I've followed their instructions exactly, and yet it does not appear. I've tried it on Chrome, Firefox and IE8 (all on Windows XP). I'm just opening the webpage from my local system.

Interestingly I can see it working here http://www.satinbow.co.uk/xxtest.html


Can anyone solve the mystery?


Update / clues

When the page is stored on my system locally, it doesn't work (hard refreshing didn't fix it either.)

But I've put the page here: dl.dropbox.com/u/6920023/test2.html and it seems to work there.

It would be really cool know what's going on :)

Gemoets answered 18/7, 2011 at 11:48 Comment(4)
Your code works fine on FF5 Win 7. It won't work on IE7 jsfiddle.net/vBPfx Can we access the page? URL?Runner
@Runner Interestingly that link works for me on the 3 browsers the page doesn't work on, this makes it even more of a mystery.Gemoets
Try hard-refreshing it. If you can supply a URL that we can take a look that would be great!Runner
When the page is stored on my system locally, it doesn't work (hard refreshing didn't fix it either.) But I've put the page here: dl.dropbox.com/u/6920023/test2.html and now it seems to work. I really would like to know what's going on now :)Gemoets
R
11

I think it's because when it's local (not webserver) browser block the JS script (that's hosted externally) to prevent security breach. That's why it doesn't work

Link: http://ejohn.org/blog/tightened-local-file-security/

Runner answered 18/7, 2011 at 12:1 Comment(1)
@t-sudent you can install local webserver (iis or wamp or nginx etc) and host your file on localhostRunner
A
3

Another thing to check for is whether you have any ad blockers active. These can disable the +1 button and move the iframe containing the button out of the screen.

Apterous answered 29/4, 2013 at 21:26 Comment(0)
H
0

Working on my open source project, http://code.google.com/p/gwt-socialmedia,

i have discovered another reason that can cause the +1 button not to render: You forgot to define the "URL to +1": It must be a valid URL to an accessible website (so http://localhost won't work for i.e.).

Indeed, the PlusOne API seems to connect to the site URL, in order to get some metadata about it (like the description, title, etc)

If you don't define the URL, Google will send you an error HTTP 400 (Bad Request), with the internal message : "The requested URL was not found on this server. " and the button will not appear...

Hope it helps!

Halette answered 20/10, 2012 at 12:54 Comment(1)
This is false. If you don't define a URL to use, it has a list of possible places it looks: developers.google.com/+/web/+1button/?hl=en#target-urlPiatt
S
0

Due to browser security(as mentioned in one of the answer) it would not display the button. Still to display google plus buttons when your file is local use local web server(WAMP/XAMPP) or you may use PHP local server https://www.sitepoint.com/taking-advantage-of-phps-built-in-server/ to host your file on your computer and you will see the button displayed in your file.

Sunroom answered 3/11, 2016 at 17:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.