Javascript Copy Selected Text Box Select All Highlight Text Form Copy Paste

Forums » Javascipt » Javascript Copy Selected Text Box Select All Highlight Text Form Copy Paste
if you need to see a demo code using javascript to select text from a textarea or a text field in a form, this is the tutorial for you. its very simle but explains how to copy and paste from a field that has highlight the text
javascript is cool for making things in your browser, here is an example script to show you how you can put this on your site so that you don't have to hit the control + c on you keyboard to copy and paste the selected text in web forms.
here is a demo:

here is the code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Select Copy Text Into Clipboard History with Javascript</title>
<!-- Begin
function copyit(theField) {
var selectedText = document.selection;
if (selectedText.type == 'Text') {
var newRange = selectedText.createRange();
theField.value = newRange.text;
} else {
alert('Alert: Select The text in the textarea then click on this button');
// End -->

<p><strong>Select Copy Text Into Clipboard History with Javascript by </strong></p>
<p><strong>1. Hight the text inside the text area below</strong></p>
<p><strong>2. Click on the form button, this will copy the text into your clipboard (basically the same as hitting control + c on your keyboard)</strong></p>
<form name="javascript">

<input onclick="copyit(this.form.text_select)" type="button" value="Click Here to Copy the Highlighted Text" name="copy_button">
<textarea name="text_select" cols="35" rows="5" wrap="VIRTUAL">FREE WALLPAPERS An Amazing collection of High quality, high resolution wallpapers for your computer desktop for free. Download your favorite high resolution wallpaper for free at Our free wallpapers include a large collection of wallpapers for your computer desktop. You will find only free wallpapers, no pop-up ads, no spam, no spyware only high quality free wallpapers for your computer background. Surf with confidence.
<div align="center">
<p align="left">If you learned or liked this script, we would appriciate puting a link of <a href=""></a> on your site. If you would like to exchange links with us, please <a href="">click here</a> to exchange links </p>
<p>Hosting By <a href=""></a> </p>

Try it on your website, you will like it

here is another way to select the content in a field with javascript: check it out

javascript select all text form button

NOTE: This will work on Internet Explorer. I tried it on Mozilla Firefox but i did not do anything. i was hoping someone can help me with firefox?
the above code is does not support in firefox how to use above code.
did not work on my end, using the latest ie.
thank you
without giving your full efforts to anything in your life, you can't justify your strengths and weakness....everybody lacks something in life....nobody is populated with each and every quality, a man should have? are really think like come forward, give upper hand to us...we will try to pull you for more details log on healthylivingpvtltd or e-mail to:enquiry at (id no.393 )

its good.

i want to apply bold to the selected part of text in a textbox control.
is it possible? if so plz help me in coding.
did not work for me either...
hey go to youtubeadds.blogspot to get more friends then nigahiga!!
this is dr.dre
sorry to say but it did not work in firefox. can you send me a cross browser code for 'copy to clipboard' functionality.
i want to bold the selected text of textarea box by clicking button using javascript
please teach me how to put a value in the textbox when we click a button using java script
i find the below link was useful supported multi-browser
<a href=" logiclabz /javascript/copy-to-clipboard-with- to clipboard javascript firefox ie</a>
download java from original page then it will work see for yourself
can modify the code for this to work in firefox. this isnt working now
it's not works at all...!!! and also the demo thing up there :(

<a href=" 6raphic.blogspot ">genial</a>
Hi I thought this my be Helpful,
This is another way for highlight html page contents , we will use the power of JQuery. It works on IE,Opera,FireFox & Safari Browsers.

Please read the Article Here:
No It does not work at all in any browser. Please go for another script...................
I recently stumbled across this blog link rindovincent.blogs where there is a simple way to copy text using JavaScript. Hope it will solve some of your problems.
doesn't work
Title: Javascript Copy Selected Text Box Select All Highlight Text Form Copy Paste [789]
Tags: javascript copy selected text box select all highlight text form copy paste