Hi,

I cannot make Google Plus button visible in my tests on local machine. Do I miss anything in code below?

Thanks

<html>
  <head>
    <title>+1 demo: Basic page</title>
    <link rel="canonical" href="http://www.example.com" />
	<!-- Place this render call where appropriate -->
	<script type="text/javascript">
	  window.___gcfg = {lang: 'en-GB'};

	  (function() {
		var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
		po.src = 'https://apis.google.com/js/plusone.js';
		var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
	  })();
	</script>	
  </head>
  <body>
	<!-- Place this tag where you want the +1 button to render -->
	<g:plusone size="medium"></g:plusone>
  </body>
</html>

Dani AI

Generated

Short summary: the button not appearing was caused by testing the page outside a proper HTTP context. As noted, many browsers restrict loading and execution of remote platform scripts when a page is opened directly from the filesystem; confirmed serving the page fixed it. The fix is to run the page from a webserver and then re-check the console/network tab.

Troubleshooting checklist (quick, practical items to try if the button still does not appear):

  • Serve the page over HTTP(S) (localhost is fine). Use a tiny local server rather than double-clicking the file.
  • Open DevTools → Network and Console. Look for the platform script request (200 vs 4xx/blocked), mixed-content/CSP errors, or messages from an adblocker/extension hiding social widgets.
  • If the script loads but the widget does not render, check that the page’s canonical or the widget’s URL target is a publicly valid URL (the button associates +1s with a URL). Also ensure any language/config object is set before the platform script loads.
  • Disable extensions briefly to rule out blocking, and test in another browser.

Note for future readers: Google+ for consumers was shut down in 2019, so the legacy +1 button may no longer behave as it did in 2012. For new projects prefer modern alternatives (the Web Share API, network-specific share endpoints, or third‑party share widgets). Quick local server examples:

# Python 3
python -m http.server 8000

# Python 2
python -m SimpleHTTPServer 8000

Recommended Answers

All 2 Replies

If this is executed locally, without a webserver, then the remote Javascript file will not be executed for security reasons.

If you are running WampServer or XAMPP (assuming Windows) locally, then it should work.

Thanks it works now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.