Log in
Search

How to add a Google Plus Button on a Wikispaces page

The code to add a Google Plus Button provided by Google looks like this:

<!-- Place this tag where you want the +1 button to render -->
<g:plusone></g:plusone>

<!-- Place this tag after the last plusone tag -->
<script type="text/javascript">
(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>

Wikispaces does allow for custom script content to be added with Page Edit > Widget > Other HTML. However it performs syntax checking and will remove any code that doesn't look like valid HTML. As the line <g:plusone></g:plusone> is not made of standard tags, wikispaces will remove it.

 You have to inject the plus one element manually. Here is the code:

<!-- Place this tag where you want the +1 button to render -->
<span id="plusOne"></div>
<!-- Place this tag after the last plusone tag -->
<script type="text/javascript">
//<![CDATA[
(function() {
jQuery("#plusOne").append("<g:plusone></g:plusone>")
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>

 Click "Save". Click on the Widget again and select "Right Align"... and voila. See it in action.