|
nutballs
|
 |
« on: April 30, 2011, 09:57:24 PM » |
|
Is it possible to copy arbitrary text to the clipboard, without the user doing anything?
For example, user lands on a page, and I want to automatically copy the URL to their clipboard. I can get as far as inserting into a hidden field that I add to the page, but, copy doesn't seem to work.
document.execCommand("Copy") should work, but doesn't seem to. Did the browsers all plug this up? Also the flash trick isn't acceptable, since I need it to work on iPad and iPhone.
|
|
|
|
|
Logged
|
I could eat a bowl of Alphabet Soup and shit a better argument than that.
|
|
|
|
Bompa
|
 |
« Reply #1 on: May 01, 2011, 01:33:17 AM » |
|
|
|
|
|
|
Logged
|
"Everything that can be counted does not necessarily count; everything that counts cannot necessarily be counted." -- Albert Einstein
|
|
|
|
perkiset
|
 |
« Reply #2 on: May 01, 2011, 10:46:55 AM » |
|
I fought this one for quite a long time, having need for some copied text in a back office procedure for my retail sites. The problems are many, the solutions are fewer all the time.
The first time I did it I was able to use JS to fire a Java applet that did it. Soon it was reworked so that the user HAD to interact to make it happen. Later I used actionscript which worked best of all, but then Adobe shut that vector down - I could not fire the copy even from a button. HAD to be the user selecting Copy.
I'm thinking that the Java applet vector might now be the only way (unless you only need IE) but it was not entirely simple. And of course the user will have to have Java running to make that work.
Love to hear about your travels here. That's one trick that will never go out of style.
|
|
|
|
|
Logged
|
It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
|
|
|
|
nutballs
|
 |
« Reply #3 on: May 01, 2011, 01:46:15 PM » |
|
it seems NOTHING works in mobile safari. Including the user action of a click, allowing for js clipboard access. BLOWS. for everything else, it seems http://code.google.com/p/zeroclipboard/is the answer.
|
|
|
|
|
Logged
|
I could eat a bowl of Alphabet Soup and shit a better argument than that.
|
|
|
|
daviator
|
 |
« Reply #4 on: May 02, 2011, 01:29:22 PM » |
|
While you probably don't care about what the user thinks for the sites you are working on, I have to point out that, as a user, I'd be very dismayed to have whatever I might have in my clipboard replaced (without my okay) by whatever you want to put there. I wouldn't visit that site again. (Then again, I might not have visited that site in the first place.) 
|
|
|
|
|
Logged
|
|
|
|
|
perkiset
|
 |
« Reply #5 on: May 02, 2011, 01:35:57 PM » |
|
And then again, given the particular project, he may not care if you ever visit his site again, seeing how it may have a 30day lifespan before it's banned by Google cleverly replaced by another depository of excellent content. 
|
|
|
|
|
Logged
|
It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
|
|
|
|
daviator
|
 |
« Reply #6 on: May 02, 2011, 06:42:42 PM » |
|
Yeah, I was kinda thinking it was that sort of site. I'm hoping I'm smart enough not to navigate to it to begin with. ;-)
|
|
|
|
|
Logged
|
|
|
|
|
nop_90
|
 |
« Reply #7 on: May 02, 2011, 08:00:15 PM » |
|
I think automatic copying to the clipboard is not longer allowed be default. If I remember correctly, the was some sort of exploit you could do, by automatically copying to the clipboard. And then you would escape the sandbox.
|
|
|
|
|
Logged
|
|
|
|
|
nutballs
|
 |
« Reply #8 on: May 02, 2011, 08:50:01 PM » |
|
Yeah, I was kinda thinking it was that sort of site. I'm hoping I'm smart enough not to navigate to it to begin with. ;-)
I'll check my logs for your ip and let you know if you are 
|
|
|
|
|
Logged
|
I could eat a bowl of Alphabet Soup and shit a better argument than that.
|
|
|
|