/    Sign up×
Community /Pin to ProfileBookmark

Copy from clipboard on click

I have been searching and experimenting for the past 3 hours and have given up, I need help solving this problem. I want to be able for the text in the clipboard to be pasted wherever the mouse is clicked, no matter if it is in a form, textarea, facebook comments box or the address bar. I have found how to make it pase onclick to textarea and form but I just want it to paste whatever is in the clipboard to wherever the mouse is clicked.

Any ideas, or help?

You guessed it, as always I will provide a paypal donation, adwords coupon or facebook ad voucher for any help.

Thanks!

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@rnd_meAug 16.2011 — there are no cross browser ways to do this. old flash scripts broke with flash 10.something, and IE has blocked it by default as of ie8...
Copy linkTweet thisAlerts:
@astupidnameAug 17.2011 — Flash still works cross browser as far as I know, and I use this combination of flash and javascript called ZeroClipboard

Oh, actually just re-read the question and should clarify ZeroClipboard is not for accessing what's in the users clipboard such as pasting from it, but is rather for copying to clipboard. Have not heard of any internet applications that may access what is in a persons clipboard as that would be a major security problem. I'm thinking it could be possible via JScript (note JScript is not Javascript, is microsoft proprietary so thus limited to Internet Explorer) perhaps, but that would require the user to allow it by accepting a security warning first. If your application is meant to work on a local-file-only basis, this may be suitable option. If from internet, forget it.
Copy linkTweet thisAlerts:
@rnd_meAug 17.2011 — . If your application is meant to work on a local-file-only basis, this may be suitable option. If from internet, forget it.[/QUOTE]

actually, as of IE8, local files are restricted more than http sites. A while back, i had posted a single function to copy to clipboard that use ie controls with a flash fallback. the flash was small and was stored in the function as a dataURL.

then they changed flash so that you have to click a flash movie to perform the copy. this broke my script and made the scripting far more complex. i hadn't seen the zeroclipboard before, but it looks like it does just that. this is nice that it works, but it sucks that you need KBs of code to perform the same functionality as a right-click, left-click. still, it's nice to have options, and i appreciate astupidname posting the link.
Copy linkTweet thisAlerts:
@QuattroauthorAug 18.2011 — Yeah I have used ZeroClipboard many times in the past, it just won't do what I'm asking.

Right now I use ActionScript '[B]System.setClipboard[/B]' to copy to users clipboard.

I wonder if there is a way to do this in flash? Does anyone know any good Flash forums, the one here seems to be pretty dead?

Thanks again for all the help guys!
Copy linkTweet thisAlerts:
@astupidnameAug 18.2011 — the flash was small and was stored in the function as a dataURL[/QUOTE]
That's kinda cool and clever, did not know an swf could be used as a dataURL. I knew images can. Does that still work (swf's as dataURL)?

Right now I use ActionScript '[B]System.setClipboard[/B]' to copy to users clipboard.

I wonder if there is a way to do this in flash?[/QUOTE]


Actionscript IS flash at it's core, and System.setClipboard is what is used by the flash movie used by ZeroClipboard in fact. If it were do-able to paste from clipboard via flash, I'd imagine the Actionscript 'System' object would have a getClipboard() method, but alas it does not.

As I suggested earlier, your only choice is JScript and Internet Explorer only. If you google along the lines of "JScript paste from clipboard" you will find many examples claiming to be javascript, but are in fact JScript (JScript and javascript are barely discernable from each other, the biggest difference being JScript's proprietary MS objects and access to system).

So, I'm afraid it's either JScript or S.O.L.
Copy linkTweet thisAlerts:
@rnd_meAug 18.2011 — That's kinda cool and clever, did not know an swf could be used as a dataURL. I knew images can. Does that still work (swf's as dataURL)?
[/QUOTE]


yeah, it worked great; everything inside one pure function. the function handled appending the movie to the dom the first time it ran, bound the io to talk to the movie, and finally provided the CB functionality. now with the ui binding, it's all complicated. my swf was ~1kb. you could probably do the same treatment (only much bigger) to zeroclipboard.
×

Success!

Help @Quattro spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...