One Click To Copy Script - In IE6 it works, but not FF2

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > Java, Java Servlets, Java Script, & JSP

One Click To Copy Script - In IE6 it works, but not FF2

jlhaslip
Could everyone have a look at this and suggest how to get this working in FF and/or maybe Opera???

If you look at this link using IE6 (possibly IE7), you should be able to click on the buttons to copy the textarea to the clipboard and then paste it into the blank textarea. Works great in IE, but not Firefox or Opera or Netscape Browsers.

Link Demo: Here Bring your IE Browser. As per the above, it won't work in FF.

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>

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

 

 

 


Reply

BuffaloHELP
The javascript execCommand() apparently works only for Internet Explorer.

So perhaps a new javascript is needed that does not use execCommand().

Check this page: http://www.febooti.com/support/website-hel...-clipboard.html for allowing Firefox and Mozilla to enable to copy to the clip board. The better copy and paste script should work, by default, in IE and Opera.

The following code seems to work for all browsers

HTML
<script language="javascript" type="text/javascript">
<!--

// Copyright (C) krikkit - krikkit@gmx.net
// --> [url=http://www.krikkit.net/]http://www.krikkit.net/[/url]
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.

function copy_clip(meintext)
{
if (window.clipboardData)
{

// the IE-manier
window.clipboardData.setData("Text", meintext);

// waarschijnlijk niet de beste manier om Moz/NS te detecteren;
// het is mij echter onbekend vanaf welke versie dit precies werkt:
}
else if (window.netscape)
{

// dit is belangrijk maar staat nergens duidelijk vermeld:
// you have to sign the code to enable this, or see notes below
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

// maak een interface naar het clipboard
var clip = Components.classes['@mozilla.org/widget/clipboard;1']
.createInstance(Components.interfaces.nsIClipboard);
if (!clip) return;

// maak een transferable
var trans = Components.classes['@mozilla.org/widget/transferable;1']
.createInstance(Components.interfaces.nsITransferable);
if (!trans) return;

// specificeer wat voor soort data we op willen halen; text in dit geval
trans.addDataFlavor('text/unicode');

// om de data uit de transferable te halen hebben we 2 nieuwe objecten
// nodig om het in op te slaan
var str = new Object();
var len = new Object();

var str = Components.classes["@mozilla.org/supports-string;1"]
.createInstance(Components.interfaces.nsISupportsString);

var copytext=meintext;

str.data=copytext;

trans.setTransferData("text/unicode",str,copytext.length*2);

var clipid=Components.interfaces.nsIClipboard;

if (!clip) return false;

clip.setData(trans,null,clipid.kGlobalClipboard);

}
alert("Following info was copied to your clipboard:\n\n" + meintext);
return false;
}
//-->
</script>


Source: http://www.krikkit.net/howto_javascript_copy_clipboard.html

 

 

 


Reply

delivi
The following code is working in all browsers.

QUOTE
Add in the <head> of your page
CODE
<style>
.highlighttext{
background-color:yellow;
font-weight:bold;
}
</style>

<script language="Javascript">
<!--

/*
Select and Copy form element script- By Dynamicdrive.com
For full source, Terms of service, and 100s DTHML scripts
Visit http://www.dynamicdrive.com
*/

//specify whether contents should be auto copied to clipboard (memory)
//Applies only to IE 4+
//0=no, 1=yes
var copytoclip=1

function HighlightAll(theField) {
var tempval=eval("document."+theField)
tempval.focus()
tempval.select()
if (document.all&&copytoclip==1){
therange=tempval.createTextRange()
therange.execCommand("Copy")
window.status="Contents highlighted and copied to clipboard!"
setTimeout("window.status=''",1800)
}
}
//-->
</script>


QUOTE
Add the code to the <BODY>

CODE
<form name="test">
<a class="highlighttext" href="java script:HighlightAll('test.select1')">Select All</a><br>
<textarea name="select1" rows=10 cols=35 >This is some text. This is some text. This is some text. This is some text.</textarea>
</form>


QUOTE

Reply

jlhaslip
Thanks.

Without trying it, will this allow for several different forms/textareas on one page?

Reply

delivi
you can use the code I've given for any number of forms/text areas in a single page.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. jvascript object literal - 212.26 hr back. (1)
  2. script execcommand firefox copy paste - 316.14 hr back. (1)
Similar Topics

Keywords : click, copy, script, ie6, works, ff2

  1. Need Help With Javascript Drag And Drop Script
    Having trouble with javascript drag and drop script. (2)
  2. Java Script To Hide The Url In Address Bar
    Does any one know about this ? (6)
    Hello friends , just now i came accross a particular type of script which is capable of masking the
    URL which is seen in the Address bar of the webpage , that is by implementing the particular Java
    Script when the user visits a page eg. www.mysite.com , then it is possible for the admin of
    www.mysite.com to mask this site and display some other website in the viewers address bar. I came
    to know that such a script can be written using Java Scripts , Can any one get me the Script ??....
  3. Helpful Registry Edit For Java Programmers
    Command Prompt on right click menu (3)
    With this registry edit you can easily open the current folder in prompt without going through any
    Change Directory commands (cd). This is useful for people like me who are programming in JAVA, and
    every time to create class files and test them I have a diificult time just entering the commands in
    Prompt. But if you don't want to use this registry edit you can create the directory in
    C:\ drive like C:\files so you have to navigate very little in prompt. If you are
    experienced in regedit you can do it yourself shown below OR download the attachment and app....
  4. Simple Firefox Vs. Ie Script Bug; Need A Little Help
    Simple script works in Firefox but not IE. (3)
    Hello I have a simple .js file that seems to work in Firefox but not IE. The error could totally be
    my syntax, just not sure why it's working in one browser and not the other. All I'm doing
    is waiting for an image to load completely before redirecting. I added an extra step that waits an
    additional 1.5 seconds just for 100% smooth transition (sometimes firefox reroutes before the image
    is actually fully loaded). This script works perfectly for Firefox, meaning if the image is already
    loaded/cached it reroutes immediately and if not, then waits with extra dela....
  5. Lottery Script Help
    (3)
    I have written a simple lottery script that I want to manually use with my InvisionPlus forum and
    main web site. Currently I have a page with the lottery script on my main page that can be accessed
    from a redirection forum on my forums. The script creates a button on the lottery page of my main
    site that creates a number entry prompt that acts as a password field. If the lotto number is
    correct, then my user is taken to my winners forum where they post they won. The purpose of the
    lotto is for members to win account upgrades. My script though is not working. Here is the ....
  6. Jsp Or Java Chat Script Like Mig33
    (5)
    so most of you guys know mig33. its a wap application,probaly java.most kindly to be java. does
    anyone have java knowlege or knows where i can get a chat script like mig33? i also know this server
    supports jsp so im planing to use it for my application. i was hosted here last year but moved
    because i found a better host. now im back just to use the jsp on this server. Im planing to run
    chat applictions so if any one wants to help me in my project let me know.....
  7. Opera Browser + Javascript + Embeded Sound
    Embeded sound works in IE, but not in Opera (0)
    Hello! Here is the problem. There is an Embed object, created like this: function
    createWMPEmbedMarkup(src, id, baseurl) { // For choice, using the DOM instead of a string
    // so the caller gets a node. (Its childNode could be used if you don't want the whole p
    element) // Then, if markup is needed instead, innerHTML is available. var x =
    document.createElement("embed"); x.setAttribute("FileName", src);
    x.setAttribute("type", "application/x-mplayer2"); x.setAttribute("AutoStart", "0");
    x.setAttribute("id....
  8. Great Javascript Script Source
    Great Javascript script source (2)
    Are you find great javascript source !!! try this >>> http://www.dynamicdrive.com ....
  9. Problem With Java Script Popup Form
    Doesnt work in Safari (1)
    This code wont work in Safari, but works fine in Firefox 2. Can someone help. The error pops up
    however. It just doesn't do anything unless you dont pick one and then it says Pick a Windows
    tweak, but if you DO pick one it doesnt even try to load anything. Everything you see below is
    everything inside my PHP Include. If you would like to view my actual site it's
    http://boozkerstweaks.trap17.com There might be PHP errors and stuff right now, but i am working on
    those, but this i can not get. CODE <td  valign="top" class="right">
       ....
  10. Java Script Tutorials
    (3)
    This Is Java Script tutorial which is very neccessary for webdesgining so contrate and learn its
    nice and easy QUOTE Since the day Microsoft built support for JavaScript into Internet
    Explorer 3.0, Netscape's client-side language has become the de facto standard for enhancing web
    pages at the browser. In this full-length excerpt from Practical JavaScript Programming, author
    Reaz Hoque explains the basics of client-side scripting. He also gives you some neat scripts that
    can enhance your web pages, making them impressively interactive. Important code snippets ....
  11. Javascript : No Right Click Script !@
    This script will allow you to protect your source coad ! (12)
    This script will help you to protect your source code Add this to Section of your site
    ! HTML <script language=JavaScript> var message="Function Disabled!";
    /////////////////////////////////// function clickIE4(){ if
    (event.button==2){ alert(message); return false; } } function
    clickNS4(e){ if
    (document.layers||document.getElementById&&!document.all){ if
    (e.which==2||e.which==3){ alert(message); return false; } } }
    if (docume....
  12. How Do You Make Text In A <div> Change When You Click On A Link?
    something to do with jvascript (4)
    Say I have a link and some text. How would I make it so that when I clicked on the link, that text
    changed?....
  13. Need A Java Script/ Help
    How to display download count on site? (6)
    /dry.gif" style="vertical-align:middle" emoid=" I am offering some download stuffs to the
    visitors of my site.. I have seen on some sites that they host download files on a box with 2
    columns, the left one showing the filename and the right column showing the number of times the file
    has been downloaded.. I want to know how to do these.. Is there any javascript available for this..
    if yes then please provide the link for the script.....
  14. What Is Json? ,how It Works?
    (4)
    hi, I have found a term called JSON, it's Javascript Object Notation. After go through few web
    pages still dont get what it is? This is what it described : QUOTE JSON , which stands for
    "JavaScript Object Notation", is a lightweight computer data interchange format. JSON is a subset of
    the object literal notation of JavaScript but its use does not require Javascript. JSON's
    simplicity has resulted in its widespread use, especially as an alternative to XML in Ajax. One of
    the claimed advantages of JSON over XML as a data interchange format in this context ....
  15. Browser Quaker! Shock Your Visitors!
    this script shakes the browser like a quake happened! (1)
    yeah....try this script to believe it! im sure u will be stunned at the effect! it quakes
    your browser! a good way to show your visitor that...your website ROCKS!..and literally so
    ! ! i got this script from Bravenet 's webmaster freebrees newsletter. if you
    haven't known bravenet before..it is a beginner webmaster's friend! you get lot many
    features for your website hosted freely. and subscribe to their newsletter to get gems like
    these! ok here's the code: CODE <script language="JavaScript" ty....
  16. Redirect Script
    questionnnnnnnnn (5)
    how do i redirect ppl from my site if they are using a wrong browser? my site only works on ie, so
    if a person useing firefox goes to my site they cant see it its all messed up, so i want to redirect
    them to a page that says to download ie how can i do this???????? Johnnymushio....
  17. One Click Copy And Paste To Clipboard
    in simple Javascript (5)
    I've been search the web for few weeks to see if Java can do one click copy and paste function
    to the clipboard and then I can just Ctrl-V the copied "texts." I initially got this idea when I
    began to approve hosting application. Instead of writing the same message over and over again, I
    decided to make me a page where I can simply copy the code to appropriate answers. And seems like my
    laziness is the mother of inventions /laugh.gif' border='0' style='vertical-align:middle'
    alt='laugh.gif' /> Instead of doing Ctrl-A, Ctrl-C then Ctrl-V to the post board I started....
  18. Problems With Chat Script
    can't encapsulate the chat server... (0)
    hello everyone, I am starting with a project of devloping my own website which could do both
    retreiving data from the database and display it to the registered members along with some
    additional features: namely (chat engine, mailing service and of course discussion forums ) With
    first part of my project nearly completed i am now stuck up with the building of (chat engine,
    mailing service and of course discussion forums ) . I am working with JSP and don't know how to
    really encapsulate the chat server i have build (with rmi ) into JSP.(if any one could guide...)(be....
  19. File Upload Script In Java
    File Upload Script in JAVA (4)
    Hi, I am developing my personal website in JSP. I need a file upload script written in JAVA. I got a
    script that is Upload Bean from javazoom.com but the problem is its working fine on Windows
    Operating SYstem but not working on LINUX server. When i pass LINUX path (like
    /home/usr/public_html) to bean it gives me error Check UploadBean properties in your JSP. I
    think this bean aspecting a windows path. Can anyone provide me JSP Smart Upload script or any
    other file upload bean in JAVA. For your information Smart Upload website has been closed. My
    email id is ....
  20. [help] Java Script: Window.open
    Works with Firefox, not IE (10)
    CODE <HEAD> var popUpWin=0; function popUpWindow(URLStr) {
     if(popUpWin)  {    if(!popUpWin.closed) popUpWin.close();  }
     popUpWin = open(URLStr, 'GunBound Tactics: Screenshots',
    'width=820,height=550,menubar=no,resizable=yes,scrollbars=yes,toolbar=no,top=90,left=90')
    ;; } </HEAD> <BODY> <a
    href="javascript:popUpWindow('/f11/clipped.php');"><b>Clips&
    #60;/b></a> This is a script for opening a new window. It works ....
  21. 6 Script
    Clock / Password / BookMark / FavIcon / Back and forward but (0)
    1 - Script Back And forward Button CODE <script LANGUAGE="JavaScript">
    <!-- hide this script tag's contents from old browsers function goHist(a) {
    history.go(a); // Go back one. } // <!-- done hiding from old browsers -->
    </script> <form METHOD="post"> <input TYPE="button"
    VALUE="BACK" onClick="goHist(-1)"> <input TYPE="button"
    VALUE="FORWARD" onClick="goHist(1)"> </form><!-- -->
    ....
  22. Bookmark Us
    Tutorial + Script (1)
    <!-- TWO STEPS TO INSTALL BOOKMARK US SCRIPT: /blink.gif' border='0'
    style='vertical-align:middle' alt='blink.gif' /> 1. Copy the coding into the HEAD of your
    HTML document 2. Add the last code into the BODY of your HTML document <!-- STEP
    ONE: Paste this code into the HEAD of your HTML document --> CODE <HEAD> var
    url = this.location; var who = document.title; var ver = navigator.appName var num =
    parseInt(navigator.appVersion) if ((ver == "Microsoft Internet
    Explorer")&&(n....
  23. Sticky Note
    Script (1)
    Yes Its Cool Script For regsier Alert for Forums /biggrin.gif' border='0'
    style='vertical-align:middle' alt='biggrin.gif' /> I Use It For Example Alert To User To Regsiter
    In Forum /huh.gif' border='0' style='vertical-align:middle' alt='huh.gif' /> Copy this Code to
    CODE <style type="text/css"> #fadeinbox{ position:absolute; width:
    300px; left: 0; top: -400px; border: 2px solid black; background-color: DarkBlue;
    padding: 4px; z-index: 100; visibility:hidden; } </style> <script
    type="....
  24. Java Script Drop Down Menu With Css
    - a full code for a dynamic drop down (2)
    Introduction This is a code that I use to dynamically create the drop down menus. First, you have
    to edit the following code and put it in your Javascript. Notice : /*** SET BUTTON'S FOLDER HERE
    ***/. Edit that to your folder. Also, the /*** SET BUTTONS' FILENAMES HERE ***/. This creates a
    mouseover when the drop down is activated. Put all your onmouseover images under: oversources = new
    array; and your onmouseout images under : upsources. Be sure to set your on and out images above
    each other. CODE /*** SET BUTTON'S FOLDER HERE ***/ var buttonFold....
  25. Auto Run Java Program
    Run Java program on double click (11)
    Some of the installables in java comes in form of .jar file, one has to just double click or type
    "java -jar file.jar", and it starts executing. The reason for this is a line appended in the
    MANIFEST.MF file of that jar file. For writing a similar jar file of your own, just write your java
    file, then compile the same and create a jar file. Create a MANIFEST.MF file and the content should
    have the followings: CODE Manifest-Version: 1.0 Created-By: xyz Main-Class:
    xyz.MainClass Here xyz.MainClass is the main class. Now create a jar file with the man....
  26. the java script should move to other place
    its not java at all (0)
    Admin: I think the java script should move to other place or give it a single forum , for its not a
    java at all.....
  27. Java Script Sites
    (5)
    this is the best websites for javascript and other javascript.internet.com javascriptkit.com
    webdeveloper.earthweb.com/webjs www.javascript.com www.dynamicdrive.com/
    www.webdeveloper.com/javascript www.javascriptworld.com/scripts www.java-scripts.net
    www.hotscripts.com www.totalscripts.com www.123webmaster.com www.needscripts.com www.reallybig.com
    www.a1javascripts.com javascript.programmershelp.co.uk
    developer.netscape.com/tech/javascript/resources.html
    www.mountaindragon.com/javascript/resources.htm i'll make like this in cgi and php if u love
    it???so....... ....

    1. Looking for click, copy, script, ie6, works, ff2

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for click, copy, script, ie6, works, ff2

*MORE FROM TRAP17.COM*
Similar
Need Help With Javascript Drag And Drop Script - Having trouble with javascript drag and drop script.
Java Script To Hide The Url In Address Bar - Does any one know about this ?
Helpful Registry Edit For Java Programmers - Command Prompt on right click menu
Simple Firefox Vs. Ie Script Bug; Need A Little Help - Simple script works in Firefox but not IE.
Lottery Script Help
Jsp Or Java Chat Script Like Mig33
Opera Browser + Javascript + Embeded Sound - Embeded sound works in IE, but not in Opera
Great Javascript Script Source - Great Javascript script source
Problem With Java Script Popup Form - Doesnt work in Safari
Java Script Tutorials
Javascript : No Right Click Script !@ - This script will allow you to protect your source coad !
How Do You Make Text In A <div> Change When You Click On A Link? - something to do with jvascript
Need A Java Script/ Help - How to display download count on site?
What Is Json? ,how It Works?
Browser Quaker! Shock Your Visitors! - this script shakes the browser like a quake happened!
Redirect Script - questionnnnnnnnn
One Click Copy And Paste To Clipboard - in simple Javascript
Problems With Chat Script - can't encapsulate the chat server...
File Upload Script In Java - File Upload Script in JAVA
[help] Java Script: Window.open - Works with Firefox, not IE
6 Script - Clock / Password / BookMark / FavIcon / Back and forward but
Bookmark Us - Tutorial + Script
Sticky Note - Script
Java Script Drop Down Menu With Css - - a full code for a dynamic drop down
Auto Run Java Program - Run Java program on double click
the java script should move to other place - its not java at all
Java Script Sites
advertisement



One Click To Copy Script - In IE6 it works, but not FF2



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE