按钮单击时在jquery / java脚本中粘贴功能 [英] Paste function in jquery/java script on button click

查看:103
本文介绍了按钮单击时在jquery / java脚本中粘贴功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于写网站url的文本框。我在旁边放了一个按钮。

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

我想如果用户从任何地方复制网址并点击该链接按钮然后复制的URL粘贴在该文本框中。

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

现在我可以使用ctrl + v将文件粘贴到文本框中。但是移动用户无法使用该文件框。 。
所以我需要点击该按钮将复制的网址粘贴到文本框中。

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.

推荐答案

基于过去的许多SO问题......

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

我会建议,但是你已经跳过了重要的一步在你的开发过程中。您面临的问题是,您希望允许移动用户轻松地将来自其他来源的文本(特别是输入的URL很难)输入到您网站上的文本框中。退一步看看那个不涉及Javascript访问用户剪贴板的问题的其他可能的解决方案。

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.

事实上,'解决方案'你是目前正在尝试实施甚至没有帮助用户,因为点击粘贴按钮仅对移动用户有用,如果他们已经成功将某些内容复制到他们的剪贴板,并且如果他们已经管理过,那么可能他们已经知道手机浏览器的原生复制/粘贴功能如何工作,所以他们不需要你的按钮。您所描述的用户流程中有两个必要步骤:从其他来源复制URL,并将其粘贴到您的网站上。即使你目前要求的是可能的,它也只能帮助你让用户更轻松地进行第二步

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.

这篇关于按钮单击时在jquery / java脚本中粘贴功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆