MozillaZine

Not able to access window.clipboard in unsecured websites.

Discuss various technical topics not related to Mozilla.
santhosha
 
Posts: 3
Joined: December 21st, 2018, 5:48 am

Post Posted December 21st, 2018, 5:56 am

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.

DanRaisch
Moderator

User avatar
 
Posts: 121727
Joined: September 23rd, 2004, 8:57 pm
Location: Somewhere on the right coast

Post Posted December 21st, 2018, 6:02 am

Moving to MozillaZine Tech as this is not a Firefox issue.

santhosha
 
Posts: 3
Joined: December 21st, 2018, 5:48 am

Post Posted December 21st, 2018, 6:05 am

where should i post? @DanRaisch

DanRaisch
Moderator

User avatar
 
Posts: 121727
Joined: September 23rd, 2004, 8:57 pm
Location: Somewhere on the right coast

Post Posted December 21st, 2018, 6:07 am

You don't need to do anything as I've already moved your post to the more appropriate location.

santhosha
 
Posts: 3
Joined: December 21st, 2018, 5:48 am

Post Posted December 21st, 2018, 6:08 am

Ok, Thnak you @DanRaisch, tell me Where can i get the update?

DanRaisch
Moderator

User avatar
 
Posts: 121727
Joined: September 23rd, 2004, 8:57 pm
Location: Somewhere on the right coast

Post Posted December 21st, 2018, 7:26 am

You're welcome.
To what update are you referring?

mightyglydd

User avatar
 
Posts: 9478
Joined: November 4th, 2006, 7:07 pm
Location: Hollywood Ca.

Post Posted December 21st, 2018, 8:23 am

#KeepFightingMichael

tomatoshadow2

User avatar
 
Posts: 393
Joined: May 11th, 2017, 9:52 am

Post Posted December 21st, 2018, 9:09 am

@mightyglydd =D> :lol:

morat
 
Posts: 3278
Joined: February 3rd, 2009, 6:29 pm

Post Posted December 21st, 2018, 2:43 pm

Are you using the clipboard code with a click handler?

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");

It works in Chrome, but not in Firefox.

document.execCommand(‘cut’/‘copy’) was denied because it was not called from inside a short running user-generated event handler

More info
http://stackoverflow.com/questions/41094318

Return to MozillaZine Tech


Who is online

Users browsing this forum: No registered users and 1 guest