|
| |
|
|
BobbyDouglas
Posts: 5456 Joined: 5/15/2003 From: Arizona Status: offline
|
Adding a JavaScript Copy to Clipboard function - 3/1/2004 1:14:00
I am trying to add a button that will "Copy contents to clipboard". Unfortunately I am not getting the result I want. Any ideas what I should modify/add? Here is what I am currently working with: Page: mrbobdouglas[dot]com/testing/email_encryption_test.php Script: mrbobdouglas[dot]com/testing/email.js
_____________________________
Arizona Web Design - Mr Bobs Web Design in Arizona The Arizona Web Hosting Challenge
|
|
|
|
Giomanach
Posts: 6091 Joined: 11/19/2003 From: England Status: offline
|
RE: Adding a JavaScript Copy to Clipboard function - 3/1/2004 3:56:24
Bobby This is one of my own, written off the top of my head: <script language="javascript" type="text/javascript"> function copyText(theSel) { if (!document.all) return; // IE only theForm = theSel.form; theForm.copyArea.value=theSel.options[theSel.selectedIndex].value; r=theForm.copyArea.createTextRange(); r.select(); r.execCommand('copy'); } </script> HTH Dan
_____________________________
|
|
|
|
BobbyDouglas
Posts: 5456 Joined: 5/15/2003 From: Arizona Status: offline
|
RE: Adding a JavaScript Copy to Clipboard function - 3/1/2004 9:55:40
Thanks for the suggestions. I have added some code to the script, unfortunately it is not quite working right. The email.js file that the one that contains basically all of the code. Before the textarea that will be copied: <SCRIPT language="JavaScript">
<!--
function highlightmetasearch() {
document.post.message.select(); document.FORMNAME.TEXTAREANAME.focus();
}
function copymetasearch() {
highlightmetasearch();
textRange = document.post.message.createTextRange();
textRange.execCommand("RemoveFormat");
textRange.execCommand("Copy");
alert("This post has been copied to your clipboard.");
}
// -->
</SCRIPT> To display the button: <script language="JavaScript" type="text/javascript">
<!--
if ((navigator.appName=="Microsoft Internet Explorer")&&(parseInt(navigator.appVersion)>=4)) {
document.write('<INPUT type="button" class="button" value="Copy" onClick="copymetasearch();">');
} else {
document.write('<INPUT type="button" class="button" value="HIGHLIGHT TEXT" onClick="highlightmetasearch();">');
}
// -->
</script>
_____________________________
Arizona Web Design - Mr Bobs Web Design in Arizona The Arizona Web Hosting Challenge
|
|
|
|
BobbyDouglas
Posts: 5456 Joined: 5/15/2003 From: Arizona Status: offline
|
RE: Adding a JavaScript Copy to Clipboard function - 3/1/2004 15:24:10
Just updating here... THis is what I need to do next, but I need some help with it.... I am trying to figure out how to include this: <script language="JavaScript" type="text/javascript">
<!--
if ((navigator.appName=="Microsoft Internet Explorer")&&(parseInt(navigator.appVersion)>=4)) {
document.write('<INPUT type="button" class="button" value="COPY TO CLIPBOARD" onClick="copymetasearch();">');
} else {
document.write('<INPUT type="button" class="button" value="HIGHLIGHT TEXT" onClick="highlightmetasearch();">');
}
// -->
</script> Inside of this function: Encrypt(value);
numArray++;
document.write ("<table border='0' cellpadding='3' width='80%' align='center'>");
document.write (" <form action='email_encryption.php' method='get' name='emailencrypt'>");
document.write (" <tr><td valign='bottom'>");
document.write (" <input type='submit' class='input' name='submit' value='Submit' />");
document.write (" </td>");
document.write (" <td>");
document.write (" <i>Enter info to encode</i> <br />");
document.write (" <input type='text' class='input' name='encode' size='55' value='");
document.write (valueDisplay);
document.write ("' /> ");
document.write (" <input type='text' class='input' name='numarray' size='3' value='");
document.write (numArray);
document.write ("' />");
document.write (" </td>");
document.write (" </tr>");
document.write (" </form>");
document.write (" <tr><td></td>");
document.write (" <td valign='bottom'>");
document.write (" <form name='encryptedemail'>");
document.write (" <textarea class='input' name='encrypted' rows='" + outLines + "' cols='64'>");
document.write (javEncrypted);
document.write ("</textarea>");
document.write (" </form>");
document.write (" </td>");
document.write (" </tr>");
document.write ("</table>"); Any ideas?
_____________________________
Arizona Web Design - Mr Bobs Web Design in Arizona The Arizona Web Hosting Challenge
|
|
|
|
BobbyDouglas
Posts: 5456 Joined: 5/15/2003 From: Arizona Status: offline
|
RE: Adding a JavaScript Copy to Clipboard function - 3/2/2004 10:05:58
Hmmm, both ways did not quite work...
_____________________________
Arizona Web Design - Mr Bobs Web Design in Arizona The Arizona Web Hosting Challenge
|
|
|
|
AMysticWeb
Posts: 855 Joined: 10/23/2002 Status: offline
|
RE: Adding a JavaScript Copy to Clipboard function - 5/11/2004 2:34:28
Hi Bobby, I am putting in my two cents, even though it may never increase in value. Since the Copy to Clipboard function seems to be basically restricted to IE, from what I understand, why not just use a highlight all script and let them right click to copy? Of course this is a form function and might not look pretty, but it might still be effective.
_____________________________
Hope I have been of some help, Micheal [URL=http://web.archive.org/web/20060101013129/http://www.frontpageforms.com/]FrontPageForms.com-Archive Version[/URL] I am living Proof that Viral Procrastination exists!
|
|
|
|
Nigel
Posts: 382 Joined: 7/24/2002 From: Wirral - UK Status: offline
|
RE: Adding a JavaScript Copy to Clipboard function - 5/12/2004 7:44:16
Yes Bobby - you seem to have a knack of creating topics that get read a lot. 2 of them (this one and the 360 tour) have about 3500 hits between them! Nigel
_____________________________
Innerview Web Design - Virtual Tours - 360 Panoramas - Shopping carts
|
|
|
|
AMysticWeb
Posts: 855 Joined: 10/23/2002 Status: offline
|
RE: Adding a JavaScript Copy to Clipboard function - 5/12/2004 10:48:58
Hi Bobby, Yes, I have run across one or two that are set up for IE and Mozilla, but still none for NS.
_____________________________
Hope I have been of some help, Micheal [URL=http://web.archive.org/web/20060101013129/http://www.frontpageforms.com/]FrontPageForms.com-Archive Version[/URL] I am living Proof that Viral Procrastination exists!
|
|
|
|
BobbyDouglas
Posts: 5456 Joined: 5/15/2003 From: Arizona Status: offline
|
RE: Adding a JavaScript Copy to Clipboard function - 5/12/2004 16:59:17
Are we talking about NS4.x? I will never install NS on my computer. Only time I encounter it is at school, even then I have the choice to use NS or IE.
_____________________________
Arizona Web Design - Mr Bobs Web Design in Arizona The Arizona Web Hosting Challenge
|
|
|
|
AMysticWeb
Posts: 855 Joined: 10/23/2002 Status: offline
|
RE: Adding a JavaScript Copy to Clipboard function - 5/12/2004 17:07:47
Hey Bobby, Far as I know it won't work in NS period. I don't use NS myself, but I keep it around for browser preview. I have 6.1 on my PC. It's just that everything I have seen about the copy fields scripts is that they don't work in NS period. And, I think that probably millions of people are secretly using NS. I suggested the Highlight All because I use it a lot on my site.
_____________________________
Hope I have been of some help, Micheal [URL=http://web.archive.org/web/20060101013129/http://www.frontpageforms.com/]FrontPageForms.com-Archive Version[/URL] I am living Proof that Viral Procrastination exists!
|
|
|
|
AMysticWeb
Posts: 855 Joined: 10/23/2002 Status: offline
|
RE: Adding a JavaScript Copy to Clipboard function - 5/13/2004 0:26:29
Hey Bonny, Persistence pays off. Just found one Here that claims to work in all three moz,ns & IE, with some tweaking. Glad you kept this thread going. I might never have found this. I have poked around I don't know how many times, without running into this. This is the first one I ran across.
_____________________________
Hope I have been of some help, Micheal [URL=http://web.archive.org/web/20060101013129/http://www.frontpageforms.com/]FrontPageForms.com-Archive Version[/URL] I am living Proof that Viral Procrastination exists!
|
|
|
|
madramire
Posts: 1 Joined: 12/13/2005 Status: offline
|
RE: Adding a JavaScript Copy to Clipboard function - 12/13/2005 7:48:37
Been reading your posts here, found it very useful to test each script placed up here for copy to clipboard. The problem I am experiencing is that I need to use a form to create a back up of inforamtion inserted. It won't be e-mailed, I want to copy the data from several fields... text areas + input fields. I can get only one text are to copy, the last one usnig the following script: <SCRIPT language="JavaScript"> <!-- function highlightmetasearch() { document.SOAP.PROBLEM_DESCRIPTION.select(); document.SOAP.PROBLEM_DESCRIPTION.focus(); } function copymetasearch() { highlightmetasearch(); textRange = document.SOAP.PROBLEM_DESCRIPTION.createTextRange(); textRange.execCommand("RemoveFormat"); textRange.execCommand("Copy"); } function highlightmetasearch() { document.SOAP.IMPACT.select(); document.SOAP.IMPACT.focus(); } function copymetasearch() { highlightmetasearch(); textRange = document.SOAP.IMPACT.createTextRange(); textRange.execCommand("RemoveFormat"); textRange.execCommand("Copy"); } function highlightmetasearch() { document.SOAP.RESOLUTION.select(); document.SOAP.RESOLUTION.focus(); } function copymetasearch() { highlightmetasearch(); textRange = document.SOAP.RESOLUTION.createTextRange(); textRange.execCommand("RemoveFormat"); textRange.execCommand("Copy"); } function highlightmetasearch() { document.SOAP.HARDWARE.select(); document.SOAP.HARDWARE.focus(); } function copymetasearch() { highlightmetasearch(); textRange = document.SOAP.HARDWARE.createTextRange(); textRange.execCommand("RemoveFormat"); textRange.execCommand("Copy"); } function highlightmetasearch() { document.SOAP.SOFTWARE.select(); document.SOAP.SOFTWARE.focus(); } function copymetasearch() { highlightmetasearch(); textRange = document.SOAP.SOFTWARE.createTextRange(); textRange.execCommand("RemoveFormat"); textRange.execCommand("Copy"); } function highlightmetasearch() { document.SOAP.ERROR_MESSAGES.select(); document.SOAP.ERROR_MESSAGES.focus(); } function copymetasearch() { highlightmetasearch(); textRange = document.SOAP.ERROR_MESSAGES.createTextRange(); textRange.execCommand("RemoveFormat"); textRange.execCommand("Copy"); } function highlightmetasearch() { document.SOAP.Engineer_Assessment.select(); document.SOAP.Engineer_Assessment.focus(); } function copymetasearch() { highlightmetasearch(); textRange = document.SOAP.Engineer_Assessment.createTextRange(); textRange.execCommand("RemoveFormat"); textRange.execCommand("Copy"); } function highlightmetasearch() { document.SOAP.Next_Action_on_Customer.select(); document.SOAP.Next_Action_on_Customer.focus(); } function copymetasearch() { highlightmetasearch(); textRange = document.SOAP.Next_Action_on_Customer.createTextRange(); textRange.execCommand("RemoveFormat"); textRange.execCommand("Copy"); } function highlightmetasearch() { document.SOAP.Next_Action_on_Microsoft.select(); document.SOAP.Next_Action_on_Microsoft.focus(); } function copymetasearch() { highlightmetasearch(); textRange = document.SOAP.Next_Action_on_Microsoft.createTextRange(); textRange.execCommand("RemoveFormat"); textRange.execCommand("Copy"); } function highlightmetasearch() { document.SOAP.Next_Agreed_Contact_Date.select(); document.SOAP.Next_Agreed_Contact_Date.focus(); } function copymetasearch() { highlightmetasearch(); textRange = document.SOAP.Next_Agreed_Contact_Date.createTextRange(); textRange.execCommand("RemoveFormat"); textRange.execCommand("Copy"); alert("Paste the Contents of the Template into your Clarify Case by Clicking Ctrl+v"); } // --> </SCRIPT> It doesn't actually copy all the fields, I needa script that allows all input fields to be copied and then a reset button for all the fields. I will also be adding a timer function eventually and I would like to be able to use the reset button the reset that to 0 too. Any ideas how I can manipulate the script above to copy all the fields before we get into the rest?
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|