I am using paste execCommand to get the system clipboard data.
document.execCommand("Paste", null, null);
var paste = pasteTarget.innerText;
I am trying to read data in every one sec delay, but pasteTarget.innerText
is always returning null.
I am executing the above code in the handle message from native client. It seems this code is not executing on background page. How to execute the code in background page?
I am using the pepper API example(nacl_sdk\pepper_35\examples\api\input_event).
common.js
function getClipboard() {
var pasteTarget = document.createElement("div");
pasteTarget.contentEditable = true;
var actElem = document.activeElement.appendChild(pasteTarget).parentNode;
pasteTarget.focus();
document.execCommand("Paste", null, null);
var paste = pasteTarget.innerText;
console.log("paste = " + paste);
actElem.removeChild(pasteTarget);
return paste;
};
Whenever right button is clicked I am trying to get the clipboard data. But always null
is returned.
manifest.json
{
"name": "Input Event",
"version": "35.0.1916.114",
"minimum_chrome_version": "35.0.1916.114",
"manifest_version": 2,
"description": "Input Event Example",
"offline_enabled": true,
"icons": {
"128": "icon128.png"
},
"app": {
"background": {
"scripts": ["background.js"]
}
},
"key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCMN716Qyu0l2EHNFqIJVqVysFcTR6urqhaGGqW4UK7slBaURz9+Sb1b4Ot5P1uQNE5c+CTU5Vu61wpqmSqMMxqHLWdPPMh8uRlyctsb2cxWwG6XoGSvpX29NsQVUFXd4v2tkJm3G9t+V0X8TYskrvWQmnyOW8OEIDvrBhUEfFxWQIDAQAB",
"oauth2": {
"client_id": "903965034255.apps.googleusercontent.com",
"scopes": ["https://www.googleapis.com/auth/drive"]
},
"permissions": [
"clipboardWrite",
"clipboardRead"
]
}