admin管理员组

文章数量:1356373

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.

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.

Share Improve this question asked May 18, 2013 at 11:32 amit ghoshamit ghosh 2761 gold badge4 silver badges15 bronze badges 4
  • 1 Getting data from mobile's or puter's clipboard doesn't seem to be possible. – Manish Jangir Commented May 18, 2013 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 Commented May 18, 2013 at 11:38
  • stackoverflow./questions/2176861/… may help you a lot – Manish Jangir Commented May 18, 2013 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 Commented May 18, 2013 at 11:41
Add a ment  | 

1 Answer 1

Reset to default 5

Based upon many SO questions from the past...

  • JavaScript get clipboard data on paste event (Cross browser)
  • Get current clipboard content?
  • Is it possible to read the clipboard in Firefox, Safari and Chrome using Javascript?
  • How do I copy to the clipboard in JavaScript?

... 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.

本文标签: javascriptPaste function in jqueryjava script on button clickStack Overflow