admin管理员组文章数量:1404927
I wanna make a extension to copy selection to clipboasd by clicking the ContextMenu. In chrome,many people use a flash solusion.But how can use flash in ContextMenus.It seems impossible.Who can tell me a solusion?
What I did
var a = chrome.contextMenus.create({"title":copy,"context":["selection"],"onclick":copy});
function copy(info,tab){
document.execCommand('selectAll'); //just for example
document.execCommand('copy');
}
I have add clipboardWrite permisson to manifest.json.But it seems doesn't work. "permission":["contextMenus","clipboardWrite"]
I wanna make a extension to copy selection to clipboasd by clicking the ContextMenu. In chrome,many people use a flash solusion.But how can use flash in ContextMenus.It seems impossible.Who can tell me a solusion?
What I did
var a = chrome.contextMenus.create({"title":copy,"context":["selection"],"onclick":copy});
function copy(info,tab){
document.execCommand('selectAll'); //just for example
document.execCommand('copy');
}
I have add clipboardWrite permisson to manifest.json.But it seems doesn't work. "permission":["contextMenus","clipboardWrite"]
Share Improve this question edited Apr 3, 2012 at 5:55 user1309417 asked Apr 3, 2012 at 2:52 user1309417user1309417 411 silver badge4 bronze badges 3- 1 [This][1] should help. [1]: stackoverflow./questions/3436102/… – chrisjr Commented Apr 3, 2012 at 3:09
- The Experimental Clipboard API has been removed and chrome doesn't support document.execCommand("Copy") and how can I use a flash in ContextMenus. – user1309417 Commented Apr 3, 2012 at 3:45
- May be the experimental API is no longer experimental? code.google./chrome/extensions/manifest.html#permissions – Alejandro Silvestri Commented Apr 3, 2012 at 3:47
2 Answers
Reset to default 5Add this permission into your manifest.json:
"permissions": [ "clipboardWrite" ]
And to copy to clipboard:
document.execCommand('copy', false, null);
May be this helps.
A recent addition to manifest's permissions are clipboardRead
and clipboardWrite
.
Theese let your extension to use the method document.execCommand('copy')
, for example.
http://code.google./chrome/extensions/manifest.html#permissions
本文标签: javascripthow to make a chrome extension to copy selection to clipboardStack Overflow
版权声明:本文标题:javascript - how to make a chrome extension to copy selection to clipboard - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744870443a2629597.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论