• ddzc

    (@ddzc)


    Hi everyone,

    I’m trying to embed the copy to clipboard feature. Basically, I want certain text or a link highlighted and when a user clicks on the text, it copies it to your clipbaord (equivelant right click – copy).

    I can’t seem to find any scripts that work without javascript. I checked a javascript page by wordpress but i’m quite confused (I don’t have much experience with programming). Can someone break it down for me and advise on how I can accomplish the copy to clipboard feature or how to enable javascript so I can use the code given to me?

    Here is a source of the feature i’m trying to do:

    https://www.htmlgoodies.com/beyond/javascript/article.php/3458851

Viewing 10 replies - 1 through 10 (of 10 total)
  • chaoskaizer

    (@chaoskaizer)

    FYI auto-copy to clipboard (save to client memory) is consider a security threat. Most modern browser (Except for IE) doesn’t allowed this obtrusive behavior. Those script are MSIE property language its only work for MSIE browser.

    If you just want to highlight a text (for manual copy), says on input. you can try the following code

    <input type="text" value="some text here" onclick="this.select();" />

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Javascript can’t copy to the clipboard, but a tiny flash application can. Look on Google and you’ll find a compatible solution that works cross-browser.

    Thread Starter ddzc

    (@ddzc)

    Thanks for the replies,

    I actually found a very very popular website retailmenot.com. It uses what i’m trying to accomplish (also links to a site) and it works safely in all browsers without any problems and it’s not a threat. This site is the biggest coupon provider in the web and is well trusted. I looked at the code..it looks to be using javascript.

    Any suggestions on getting this to work in wordpress?

    Thanks

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    I looked at the code..it looks to be using javascript.

    Then you failed to look deep enough.

    I’m not sure I can make this any clearer. What you want is not possible using only Javascript. Really. I’m not just making this up.

    The retailmenot site in particular uses a hidden flash application, just like I stated above. It’s not obvious, but if you dig deep enough, then it is there. Here’s the SWF file for it, in fact: https://s.retailmenot.com/ui/_clipboard.swf

    Google has more info on this topic: https://www.google.com/search?q=flash+clipboard

    Thread Starter ddzc

    (@ddzc)

    Hello,

    I looked into this further and yes, you are correct when saying it doesn’t use javascript only. This function uses Javascript AND Flash. The code in the javascript calls the flash object. Again, what am I asking is how to enable javascript coding in wordpress. WordPress only runs html, I can’t use any javascript coding in wordpress.

    Here is two examples which I would love to try and run in wordpress

    https://www.jeffothy.com/weblog/clipboard-copy
    https://ajaxian.com/archives/auto-copy-to-clipboard

    Any suggestions please??

    Thank You

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    I can’t use any javascript coding in wordpress.

    Huh? Says who? You can use javascript in WordPress just fine. Just put the javascript into your theme, or even directly into your post content. It’ll work. I’ve done it dozens of times.

    If you use the visual editor, turn it off so you can edit the raw html of your posts.

    For this case though, you probably want to put the code into your theme. So go edit your theme’s files directly and put your code in there, wherever it belongs.

    Thread Starter ddzc

    (@ddzc)

    Hey otto,

    I actually did get this working but not how I want it. I can get it working with specified text and a button. I need to get this working within a link exactly like retailmenot. I also need it to work with firefox, safari, etc. Would you be able to assist me any further, I can give you a bit of cash for it as well if you can build the script that will work identical to retailmenot. Let me know, thx. ([email protected])

    Hey guys. I’m having the same problem and I can’t get it done. Basically I found the code to place a “copy to the clipboard comand” and the text to be copied is actually a video embedded code. Seems to work fine as long as I don’t place a code in the text area. If I do, it actually plays the video instead of showing the code to be copied. Any help will be very much appreciated. I’m trying to accomplish this in wordpress. This is the code I’m trying to show in the copy to clipboard text area:
    <object id=”csSWF” classid=”clsid:d27cdb6e-ae6d-11cf-96b8-444553540000″ width=”256″ height=”178″ class=”alignleft” codebase=”https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0″&gt;
    <param name=”src” value=”https://lifetakesgbg.com/Videos/NBSPromoGBGPayPlan256x160/NBSPromoGBGPayPlan256x160_controller.swf”/&gt;
    <param name=”bgcolor” value=”#1a1a1a”/>
    <param name=”quality” value=”best”/>
    <param name=”allowScriptAccess” value=”always”/>
    <param name=”allowFullScreen” value=”true”/>
    <param name=”scale” value=”showall”/>
    <param name=”flashVars” value=”autostart=true”/>
    <embed name=”csSWF” src=”https://lifetakesgbg.com/Videos/NBSPromoGBGPayPlan256x160/NBSPromoGBGPayPlan256x160_controller.swf&#8221; width=”256″ height=”178″ bgcolor=”#1a1a1a” quality=”best” allowScriptAccess=”always” allowFullScreen=”true” scale=”showall” flashVars=”autostart=true&thumb=FirstFrame.png&thumbscale=35&color=0x1A1A1A,0x1A1A1A” pluginspage=”https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash”></embed&gt;
    </object>

    Thanks

    Any help?

    Are people just too lazy these days to highlight text they want and then hit CTRL+C?

    This is ludicrous.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Copy to Clipboard feature – Javascript’ is closed to new replies.