Putting a Copy to Clipboard Button on a Webpage
by EliyahuGeorgios in Circuits > Computers
2771 Views, 10 Favorites, 0 Comments
Putting a Copy to Clipboard Button on a Webpage
This may sound simple, and I might look sillytfor putting it on Instructables, but in reality, it's not that easy. There is CSS, Jquery, HTML, some fancy javascript, and, oh well, you know.
Create a Pen
There is this cool site called Codepen. In the past, just to code in HTML, I used to have to
- Launch File Explorer.
- Go to My Documents.
- Create a txt file.
- Rename that file to "MyHTMLDoc.html".
- Hit OK to the warning dialog.
- Close File Explorer.
- Open Visual Studio, which takes five minutes.
- Open the file in Visual Studio, which takes another five minutes. VS is very slow.
- Start <coding/>.
- When I am done, I must open the file in Edge to view my work.
Now, all you need to do is
- Launch Edge.
- Go to https://www.codepen.io.
- In the upper-right corner, hit new Pen.
- Start Coding.
See how much easier it is? Just enter your JS, CSS, and HTML in their respective boxes. The results show up automatically on the right.
In fact, Codepen is soooo much better, that I recommend you to go create your account right now. Yeah, I hate to be the one advertising, but I can't help it. It is much better. There's nothing I can do about it.
Or, if you don't want to create an account, you can go create a pen without an account. You can save your pen under the username "Captain Anonymous".
Add References
Since we are going to be using Jquery and this (really) cool thingajammy called "Balloon.css", we must add references first. If you are new, I will tell you how to do this in Codepen.
- Click Settings.
- Depending on whether the reference is a style-sheet or a script, click either CSS or Javascript.
- Under Add External (Javascript or CSS) add the references.
Add:
bla bla bla: BLAAAAAAA!!!!
Now remove that and put in the HTML <script> tag linking to your favorite CDN for Jquery and Balloon.css.
Code
Below that, add this code.
https://codepen.io/slate-coding/pen/oepQpX
Copy/paste the code to your pen.