The problem: I was unable to find an easy solution which does not require complex scripts for adding a “Donate Bitcoins” button to my website. Most Websites just display the full Bitcoin address, which is large and ugly. So I tried to create my own.
The solution idea: I wanted to create a Button which allows the user to copy the Bitcoin address to the clipboard so I don’t have to display it on my website. Stackoverflow showed a nice idea: Display a prompt which allows the user to copy the address himself. Standard JavaScript function supported by most browsers. Does not require any libraries. This is also the most reliable solution since directly writing to the clipboard with JavaScript is not allowed by many browsers. There are libraries to allow scripts to write to the clipboard it but they commonly use Flash, which is overkill IMHO.
(TLDR) The solution – don’t forget to replace my Bitcoin address with yours:
<a href="javascript:void(0);" onclick="javascript:window.prompt ('Please copy-paste my Bitcoin address to your Bitcoin software - I cannot do it automatically.\nTo copy it, right-click the selected text and select \'Copy\'.\nThen right-click the address field in your Bitcoin software and select \'Paste\'.', '18bkQoBGCZwwP1JhkbAqifEQHyq2cYVv6v');"> <img src="http://www.ecogex.com/bitcoin/pack/ribbonDonateBitcoin.svg" width="104" height="26" alt="Donate Bitcoin" /> </a>
What it looks like – use this to donate some coins for me while you’re at it ;)
Additional information: The image – which I found here under the Free Art License – is a SVG so you can specify any size you want, it will scale cleanly.
a WordPress rating system