Welcome Guest ( Log In | Register )




                Web Hosting Guide

 
Closed TopicNew Topic
One Click To Copy Script, Works in IE6 but not any other Browsers
jlhaslip
post Feb 17 2007, 06:19 AM
Post #1


Advanced Member
Group Icon

Group: Members
Posts: 196
Joined: 15-November 05
From: Inland from the Left Coast of Canada
Member No.: 9,627
myCENTs:43.09


As a project to "boilerplate" some text, I had this idea of making a couple of textareas in html and having a single click on the input button copy the contents to the clipboard and then pasting the text into another blank textarea. Several textareas would contain the different pieces of text and I would then be able to 'assemble' the full text into the 'blank' textarea and then, of course, copy this entire piece to the clipboard and migrate it to the final spot for copying. Anyways, BuffaloHELP had the basic code for the javascript, but it seems that this code only works in Internet Explorer. I understand the Gecko Browsers (and Opera/Netscape) use a different scripting language.
Could you folks have a look to see what would need to be done to this code to get it working cross-browser?

Thanks a bunch...

LINK REMOVED jlhaslip

Source code here:

[codebox]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Javascript for one-click highlight and copy to clipboard</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" >
<meta http-equiv="Content-Style-Type" content="text/css" >
</head>
<body>

&lt;script type="text/javascript">
function doact(d)
{
var doc = eval("document.readme."+d);
cp = doc.createTextRange();
doc.focus();
doc.select();
cp.execCommand("Copy");
}
</script>
<div>
<form name="readme" action="#">
<p style="float:left">
<textarea name="text1" cols="10" rows="2">
1. -Your basic HTML codes can be entered here.</textarea>
<br>
<input onclick="doact('text1')" type="button" value="Quote">
</p>

<p style="float:left">
<textarea name="text2" cols="30" rows="2">
2. -This textarea is the second textbox for copying.
2. -This textarea is the second textbox for copying.</textarea>
<br>
<input onclick="doact('text2')" type="button" value="Longer Quote">
</p>

<p style="float:left">
<textarea name="text3" cols="40" rows="2">
3. -This textarea is to demonstrate the inclusion of the third textbox for copying.
3. -This textarea is to demonstrate the inclusion of the third textbox for copying.
3. -This textarea is to demonstrate the inclusion of the third textbox for copying.</textarea>
<br>
<input onclick="doact('text3')" type="button" value="Still A Longer Quote">
<br style="clear:both" />
</p>
<p style="clear:both" ></p>
<p><strong>Add Information To <em>This Work Area</em> To Build Your Posting</strong></p>
<p>
<textarea name="text4" cols="60" rows="8">
</textarea>
<br>
<input onclick="doact('text4')" type="button" value="Main Text area">
<input type="reset" value="Clear The Form">
</p>
</form>
</div>
</body>

</html>[/codebox]

Forever grateful!

This post has been edited by jlhaslip: Mar 11 2007, 02:16 AM
Go to the top of the page
 
+Quote Post

Closed TopicNew Topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Collapse

> Similar Topics

    Topic Title Replies Topic Starter Views Last Action
No New Posts   0 moonlifee 17 18th November 2009 - 03:20 AM
Last post by: moonlifee
No New Posts   14 kanade 4,273 12th November 2009 - 07:55 PM
Last post by: iG-Ram
No New Posts 5 Niru 3,805 5th November 2009 - 08:04 AM
Last post by: iG-balajee
No New Posts  
4 PHP
7 bluefish 2,804 3rd November 2009 - 09:29 PM
Last post by: HannahI
No New Posts   15 whistle 4,588 31st October 2009 - 08:43 PM
Last post by: iG- ringku2k
No New Posts   10 yordan 2,225 27th October 2009 - 11:31 PM
Last post by: HannahI
No New Posts   2 pbolduc 2,767 3rd October 2009 - 08:20 PM
Last post by: iG-Andrew
No new   22 TavoxPeru 10,417 2nd October 2009 - 07:53 AM
Last post by: iG-Mel
No New Posts   11 soleimanian 4,205 22nd September 2009 - 12:01 PM
Last post by: iG-
No New Posts   7 Eggie 2,079 9th September 2009 - 02:22 AM
Last post by: iG-nate
No New Posts   1 willwill258 84 29th August 2009 - 01:24 AM
Last post by: takerraj
No New Posts   12 m3th 6,637 29th August 2009 - 12:16 AM
Last post by: dmnhunter
No New Posts 10 Niru 1,270 23rd August 2009 - 11:33 AM
Last post by: yordan
No New Posts   11 master_nero 2,501 30th July 2009 - 01:00 AM
Last post by: iG-Al
No New Posts   2 Alex@Synergy 4,002 23rd July 2009 - 02:11 PM
Last post by: iG-peter


Web Hosting Powered by ComputingHost.com.