Jon Cox
Jon Cox

Reputation: 10922

Google plus one button not showing

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 :)

Upvotes: 7

Views: 15804

Answers (4)

Neerali Acharya
Neerali Acharya

Reputation: 623

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.

Upvotes: 0

Srikumar
Srikumar

Reputation: 421

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.

Upvotes: 3

tinesoft
tinesoft

Reputation: 766

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!

Upvotes: 0

ysrb
ysrb

Reputation: 6740

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/

Upvotes: 11

Related Questions