Hello,
can you please suggest me how to enable window.clipboard in unsecured web pages, currently i have a project where i need to copy selected text and paste it in somewhere. So am using document.execCommand("copy"); but am not able to find window.clipboard in developer tool. So not able to copy the things to clipboard.
Or suggest how can I enable it using javascript.
Not able to access window.clipboard in unsecured websites.
-
- Posts: 3
- Joined: December 21st, 2018, 5:48 am
- DanRaisch
- Moderator
- Posts: 127234
- Joined: September 23rd, 2004, 8:57 pm
- Location: Somewhere on the right coast
Re: Not able to access window.clipboard in unsecured website
Moving to MozillaZine Tech as this is not a Firefox issue.
-
- Posts: 3
- Joined: December 21st, 2018, 5:48 am
Re: Not able to access window.clipboard in unsecured website
where should i post? @DanRaisch
- DanRaisch
- Moderator
- Posts: 127234
- Joined: September 23rd, 2004, 8:57 pm
- Location: Somewhere on the right coast
Re: Not able to access window.clipboard in unsecured website
You don't need to do anything as I've already moved your post to the more appropriate location.
-
- Posts: 3
- Joined: December 21st, 2018, 5:48 am
Re: Not able to access window.clipboard in unsecured website
Ok, Thnak you @DanRaisch, tell me Where can i get the update?
- DanRaisch
- Moderator
- Posts: 127234
- Joined: September 23rd, 2004, 8:57 pm
- Location: Somewhere on the right coast
Re: Not able to access window.clipboard in unsecured website
You're welcome.
To what update are you referring?
To what update are you referring?
- mightyglydd
- Posts: 9813
- Joined: November 4th, 2006, 7:07 pm
- Location: Hollywood Ca.
Re: Not able to access window.clipboard in unsecured website
#KeepFightingMichael and Alex.
-
- Posts: 435
- Joined: May 11th, 2017, 9:52 am
-
- Posts: 6429
- Joined: February 3rd, 2009, 6:29 pm
Re: Not able to access window.clipboard in unsecured website
Are you using the clipboard code with a click handler?
I tried the following code in the error console.
It works in Chrome, but not in Firefox.
http://stackoverflow.com/questions/41094318
I tried the following code in the error console.
Code: Select all
function readFromClipboard() {
var element = document.createElement("textarea");
document.body.appendChild(element);
element.focus();
element.select();
document.execCommand("paste", false, null);
element.remove();
return element.value;
}
function writeToClipboard(text) {
var element = document.createElement("textarea");
document.body.appendChild(element);
element.value = text;
element.focus();
element.select();
document.execCommand("copy", false, null);
element.remove();
}
writeToClipboard("abracadabra");
More infodocument.execCommand(‘cut’/‘copy’) was denied because it was not called from inside a short running user-generated event handler
http://stackoverflow.com/questions/41094318