Results 1 to 22 of 22
  1. #1
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    Click to Copy Javascript?
    Anyone familiar with javascript that allows you to click on some defined text on a page and have it copied to your clipboard? Point me in the right direction? I think Snib may be familiar with this.

  2. #2
    Newbie BoostSilver's Avatar
    Join Date
    October 12th, 2009
    Location
    Numismatic Maniac
    Posts
    28
    The copy feature only works in IE, firefox/mozzilla/netscape can not handle it...

    I have this set up on one of my pages for a coupon code, but cant post affiliate link here, as I'm new I cant PM it to you either, but if you PM me I can probably reply...

    Edit: the highlight feature is still good to use, and all they need to do is hit Ctrl+C or X
    Last edited by BoostSilver; October 21st, 2009 at 05:42 PM. Reason: highlight

  3. #3
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    I have seen it on a website that it did indeed work on Firefox so I know something exists.

  4. #4
    Moderator BurgerBoy's Avatar
    Join Date
    January 18th, 2005
    Location
    jacked by sylon www.sylonddos.weebly.com
    Posts
    9,618
    Quote Originally Posted by BoostSilver
    The copy feature only works in IE, firefox/mozzilla/netscape can not handle it...

    I have this set up on one of my pages for a coupon code, but cant post affiliate link here, as I'm new I cant PM it to you either, but if you PM me I can probably reply...

    Edit: the highlight feature is still good to use, and all they need to do is hit Ctrl+C or X
    You can't read PMs either until you have more post.

    Vietnam Veteran 1966-1970 USASA
    ABW Forum Rules - Advertise At ABW

  5. #5
    Affiliate Manager
    Join Date
    April 25th, 2008
    Location
    Lexington KY
    Posts
    64
    Most people do this using flash. This eliminates most of the browser issues.

  6. #6
    ABW Ambassador
    Join Date
    March 2nd, 2007
    Posts
    1,470
    flash is the way to go

  7. #7
    Newbie BoostSilver's Avatar
    Join Date
    October 12th, 2009
    Location
    Numismatic Maniac
    Posts
    28
    Arrow Try This
    This is what I use, auto selects on JS focus, no copy button,but makes it a little easier...

    Code:
    <input type="text" id="textfield" onfocus="javascript: this.select();" value="DISC10-4499" />

  8. #8
    Newbie A.J. - Sararte's Avatar
    Join Date
    October 11th, 2009
    Posts
    6
    SeymourButts, zeroclipboard is a good script to start ( code.google.com/p/zeroclipboard/ )

  9. #9
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    Thanks, I will check that out A.J.

  10. #10
    ABW Ambassador Snib's Avatar
    Join Date
    January 18th, 2005
    Location
    Virginia
    Posts
    5,303
    Yes, I suggest Zeroclipboard. It's pretty much what all the coupon sites use. I've used it a couple times and it's pretty well done.

    - Scott
    Hatred stirs up strife, But love covers all transgressions.

  11. #11
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    Not sure why, but I can't seem to get Zeroclipboard to work.

    I have uploaded and included the ZeroClipboard.js file and the ZeroClipboard.swf file.

    When I click a link in mydiv, the Jquery is called. Both "Got a Click" and "Copy to Clipboard" alerts fire off. I do a setText() to "Hello" so I am expecting to paste "Hello", but there's nothing copied. I just want to copy some text on the click, which seems pretty trivial. Is there something I am suppose to load when the page loads? Seem to be spinning my wheels.

    Code:
    //On main php page
    <script src="/js/jquery.js" type="text/javascript"></script>
    <script src="/js/ZeroClipboard.js" type="text/javascript " ></script>
    
    //Jquery code
    $n("#mydiv").click(function() {
    alert('Got a click');
    ZeroClipboard.setMoviePath( 'http://www.mydomain.com/ZeroClipboard.swf' );
    var clip = new ZeroClipboard.Client();
    clip.setText("Hello");\
    alert('Copy to Clipboard');
    
    });

  12. #12
    The "other" left wing davidh's Avatar
    Join Date
    January 18th, 2005
    Location
    Boston
    Posts
    3,492
    If you don't mind having the text to copy displayed within a text box (would also be able to copy just by scrolling over, without having to click) go to just about any Myspace Comments site and check the source code.
    CUSTOM BANNERS by GRAPHICS CANDY ~ Banner Sets and Website Graphics ~ Professional design, reasonable rates
    DESIGNER DOG CHECKS ~ We double-dog dare ya to write one!

  13. #13
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    I don't really frequent MySpace, but I just looked real quick and not sure where to look for that.

  14. #14
    The "other" left wing davidh's Avatar
    Join Date
    January 18th, 2005
    Location
    Boston
    Posts
    3,492
    Here's the code you can try and see if it's suitable for your purpose. Your code, link, or whatever will be displayed in a text box and will automatically be highlighted/selected when scrolled over.

    Code:
    <textarea onFocus=this.select() onMouseOver=this.focus()>
    PUT YOUR TEXT OR LINKS TO BE COPIED HERE
    </textarea>
    CUSTOM BANNERS by GRAPHICS CANDY ~ Banner Sets and Website Graphics ~ Professional design, reasonable rates
    DESIGNER DOG CHECKS ~ We double-dog dare ya to write one!

  15. #15
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    But I want to copy text to the user's clipboard upon clicking on it.

  16. #16
    Moderator BurgerBoy's Avatar
    Join Date
    January 18th, 2005
    Location
    jacked by sylon www.sylonddos.weebly.com
    Posts
    9,618
    Quote Originally Posted by SeymourButts
    But I want to copy text to the user's clipboard upon clicking on it.
    Is this what you want? http://www.htmlgoodies.com/beyond/ja...le.php/3458851

    IE gives a warning when you use a code like that. Are you sure that's what you want to do?

    Vietnam Veteran 1966-1970 USASA
    ABW Forum Rules - Advertise At ABW

  17. #17
    ABW Ambassador Snib's Avatar
    Join Date
    January 18th, 2005
    Location
    Virginia
    Posts
    5,303
    Butts, the way Zeroclipboard works is it floats a flash widget over a div so when you click in the div the flash widget is clicked instead. So the problem is that you haven't tied your div to the flash widget. There is a "glue" function within Zeroclipboard that lets you tie a div to the widget that you're missing. The code you have won't work because you're triggering based on a Javascript click, not a flash click. Check their examples to see how to do it.

    - Scott
    Hatred stirs up strife, But love covers all transgressions.

  18. #18
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    Quote Originally Posted by BurgerBoy
    Is this what you want? http://www.htmlgoodies.com/beyond/ja...le.php/3458851

    IE gives a warning when you use a code like that. Are you sure that's what you want to do?
    No, like I said, that's why I am trying to implement ZeroClipboard.

  19. #19
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    Finally got it working.

  20. #20
    ABW Ambassador Snib's Avatar
    Join Date
    January 18th, 2005
    Location
    Virginia
    Posts
    5,303
    Quote Originally Posted by SeymourButts
    Finally got it working.
    Excellent.
    Hatred stirs up strife, But love covers all transgressions.

  21. #21
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    Well, I spoke to soon. The Click/Copy using ZeroClipboard is working.

    However, by adding ZeroClipboard.js to the page, I broke that auto complete functionality in my search box that uses prototype.js and scriptaculous.js.

    If I remove the ZeroClipboard.js and the associated javascript that goes with it from the page, the auto complete starts working again.

    Oddly, everything works in IE, it's FF and Opera that aren't working.

  22. #22
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    Everything is happy again. The auto complete function and the click to copy function have made peace with each other in IE, FF, and Opera.

  23. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. HD warning noise? Click ... click ... click
    By writerguy in forum Midnight Cafe'
    Replies: 9
    Last Post: December 25th, 2007, 01:46 PM
  2. Is there a way to get a copy
    By trcyph in forum Midnight Cafe'
    Replies: 6
    Last Post: June 9th, 2007, 03:34 PM
  3. Copy Writer Signs up - Free Copy coming
    By Chris - AMWSO in forum AMWSO
    Replies: 2
    Last Post: April 20th, 2005, 09:21 AM
  4. Do you keep a copy?
    By frank3iii in forum Midnight Cafe'
    Replies: 15
    Last Post: June 17th, 2003, 10:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •