Google plus one button not showing

久未见 提交于 2019-12-10 04:17:06

问题


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


回答1:


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/




回答2:


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.




回答3:


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!




回答4:


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.



来源:https://stackoverflow.com/questions/6732432/google-plus-one-button-not-showing

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