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
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744870443a4598229.html
评论列表(0条)