为什么document.execCommand(“粘贴”)无法在Google Chrome中运行? [英] Why is document.execCommand("paste") not working in Google Chrome?

查看:2440
本文介绍了为什么document.execCommand(“粘贴”)无法在Google Chrome中运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的扩展程序有问题。我想从剪贴板粘贴数据。

I have a problem with my extension. I want to paste data from the clipboard.

到目前为止,我已经得到了这个:

So far, I've got this:

function pasteAndGo()
{
    document.execCommand('paste')
    alert("Pasted")
}

警报出现,但没有任何粘贴。

The alert comes up, but nothing has been pasted.

我感觉这是需要改变的文件部分,但我不知道该怎么做。有什么想法吗?

I've got a feeling it's the document part that needs changing, but I don't know what to do. Any ideas?

推荐答案

你不能在常规页面上执行它,只能在后台页面中执行。

You can't execute it on a regular page, only in a background page.

这篇关于为什么document.execCommand(“粘贴”)无法在Google Chrome中运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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