Posts

Showing posts from February, 2021

Adding "Copy to clipboard" buttons to Google Sites

Image
 Google Sites has many good aspects, but it is pretty tight when it comes to customizations. I have written some pages that ask the reader to copy some code and run it in a command window. The code is typically several lines, and selecting it can be a bit awkward. In fact, one tester missed one character when selecting the text, and confusion ensued. After a fair amount of bumping into walls, I have finally found something that's not perfect, but it works. The main challenge is that Google places embed widgets deep in very tightly controlled sandboxes, so forget about accessing the content of the page from your JavaScript code -- that's never happening. Let's say you want a button that puts the following multi-line text in the clipboard: Now is the time Four score and seven years ago When in the course of human events Insert an Embed widget and give it the following code: <p id="txtBuff" style="height: 0px; width: 0px; clip-path: circle(0); font-size: 0px;...