我正在尝试阅读Google Chrome扩展中的剪贴板文本。到目前为止,我已经尝试过使用这些代码,并且它返回给我的是未定义的。请帮助我。如何阅读谷歌Chrome扩展中的剪贴板文本
在background.html我的代码是
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
if (request.method == "getClipData")
sendResponse({data: document.execCommand('paste')});
else
sendResponse({}); // snub them.
});
在我的内容脚本我的代码是
chrome.extension.sendRequest({method: "getClipData"}, function(response) {
alert(response.data);
});
[为什么document.execCommand('paste')不能在我的扩展中工作](http://stackoverflow.com/questions/8503738/why-document-execcommandpaste-is-not-working-in -my-extension) – pimvdb 2011-12-14 18:29:23