2

I've been trying to add a google plus icon to my webpage but I haven't been able to make it work. I use HTML5 and I have tried doing this:

I added the following <script> before the </body>

<script src="https://apis.google.com/js/plusone.js"></script>

and this in the place I want it to be shown.

<g:plusone size="tall" count="true"></g:plusone>

but I get the following error

Refused to display 'https://apis.google.com/u/0/se/0/_/+1/fastbutton?usegapi=1&size=tall&count=…refresh&id=I0_1425069928860&parent=file%3A%2F%2F&pfname=&rpctoken=36362517' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

I also checked this question but the &output=embed solution isn't working for me.

I was able to use the facebook and twitter share using iframe but I can't find an example for doing the same for the google +1.

NOTE: The page I'm making is part of an assignment and it's not supposed to be online until after the deadline. I don't know if the problem is because the page is still local on my computer.

Community
  • 1
  • 1
Nena
  • 376
  • 1
  • 6
  • 15
  • Testing locally is probably the issue indeed. If you want to test on your own machine, but have a more 'real world like' configuration and setting, you can try setting up your own XAMPP/WAMP server. Just google it. – Bram Vanroy Feb 27 '15 at 21:11
  • Are you testing it using a WAMP/XAMP server on localhost, or just by executing the HTML files on your browser? – Nick Louloudakis Feb 27 '15 at 23:00
  • I was just running the file on my browser until now. – Nena Feb 28 '15 at 03:45
  • 1
    If you want a simple solution for setting up a server-like environment without having to setup full stack server environment, try Brackets live preview feature: http://brackets.io/ – Joram van den Boezem Feb 28 '15 at 13:45

1 Answers1

1

After setup of the page online, it seems that the problem was because the page was not online.

After some more research, I found out that an HTTP server is needed. Most browsers, for security reasons, by default they use the SAMEORIGIN policy and they don't allow access to different domains.

Here's a link that was very instructive on that part: https://security.stackexchange.com/questions/67889/why-do-browsers-enforce-the-same-origin-security-policy-on-iframes

Community
  • 1
  • 1
Nena
  • 376
  • 1
  • 6
  • 15