8

I have a textbox for write website url.And I place a button beside that.

I want if a user copy a url from any place and click on that button then the copied url paste in that textbox.

Now I can use ctrl+v to paste the url in the text box.But then mobile user not able to use that. So I need on click on that button the copied url paste in textbox.

Any help highly appreciable and thanks in advance.

amit ghosh
  • 276
  • 1
  • 4
  • 15
  • 1
    Getting data from mobile's or computer's clipboard doesn't seem to be possible. – Manish Jangir May 18 '13 at 11:36
  • I have no code now.I only have a html textbox and a html button.I want on click that button if user copy any url from any place then it paste to the textbox. This is just like the paste functionality which we did on rightclick( or ctrl+v) on windows.I need the same on a button click. – amit ghosh May 18 '13 at 11:38
  • http://stackoverflow.com/questions/2176861/javascript-get-clipboard-data-on-paste-event-cross-browser may help you a lot – Manish Jangir May 18 '13 at 11:38
  • @amitghosh this is bad design. Smartphones with a browser have copy and paste options. Are you planning to support even lower end phones, then you need the re-think your design because the phone might not even support javascript fully? Additionally it isn't really possible to fetch clipboard data across browsers. – gideon May 18 '13 at 11:41

1 Answers1

5

Based upon many SO questions from the past...

... the answer is probably "No, it's impossible."

I would suggest, though, that you've skipped an important step in your development process. The problem you face is that you want to allow mobile users to painlessly enter text (in particular, URLs, which are a pain to type) from other sources into a textbox on your site. Take a step back and look at other possible solutions to that problem that don't involve Javascript access to the user's clipboard.

In fact, the 'solution' you're currently trying to implement doesn't even help the user, because the 'click to paste' button is only helpful to a mobile user if they've already succeeded in copying something to their clipboard, and if they've managed that, then presumably they already know how the native Copy/Paste functionality of their phone browser works, so they don't need your button. There are two necessary steps in the user flow you've described: copying a URL from some other source, and pasting it on your site. Even if what you're currently asking for were possible, it could only possibly help you make the second step easier for the user.

Instead, I figure you should check how copy and paste work on different available brands of smart phones and their browsers. If any of them use obscure or opaque interfaces that you worry your users may be unfamiliar with, have a button near your text box that is shown only to users of those platforms that gives them platform-targeted instructions on how to use their native copy and paste functionality.

Community
  • 1
  • 1
Mark Amery
  • 143,130
  • 81
  • 406
  • 459
  • Not to mention, copy-pasting is easy on phones anyway... And since they provide a native way to do it, providing your own is kind of redundant :D – Niet the Dark Absol Jun 30 '14 at 12:59
  • 3
    @NiettheDarkAbsol I disagree that this is redundant. On most mobile devices the native way you mention requires tapping a text field > holding down for several seconds > then clicking "paste." From what Amit is describing, this would be eliminating two of the above steps; a single tap of a button. – Stout Joe Apr 14 '16 at 18:43