Welcome Guest ( Log In | Register )



 
Closed TopicStart new 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: 185
Joined: 15-November 05
From: Inland from the Left Coast of Canada
Member No.: 9,627



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:

CODE

<!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>


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 TopicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Javascript: Disable Mouse Right-click In Browser(16)
  2. Need Drop Down Menu Script(1)
  3. Slideshow Of Pictures(0)
  4. Need Opinion - Language Redirection Script...(0)
  5. Let's Make Rainbow Link(1)
  6. Bid Visitors Bye/thank U With A Popup Onunload In Just One Line!(0)
  7. Sweet Titles(0)
  8. Browser Quaker Script - Shock Your Visitors!(5)
  9. Password Protect Your Page(2)
  10. Calling Of Functions Between Mulitple External Javascript Files(2)
  11. Javascript: Browser Detection Script(0)
  12. Create And Import JavaScript Modules For A Large Script(2)
  13. JavaScript Off Redirect Script(2)
  14. Enlarge Image Script(19)
  15. Javascript Help Needed : Alert(z) Works Fine But Document.write Not(2)
  1. Love Script(3)


 



- Lo-Fi Version Time is now: 30th August 2008 - 12:38 PM