Copy to clipboard is not working in safari.

var parsedText = Pointer_stringify(text);
var textArea = document.createElement(“textarea”);

  textArea.style.position = 'fixed';
  textArea.style.top = 0;
  textArea.style.left = 0;
  textArea.style.width = '10em';
  textArea.style.height = '10em';
  textArea.style.padding = 0;
  textArea.style.border = 'none';
  textArea.style.outline = 'none';
  textArea.style.boxShadow = 'none';
  textArea.style.background = 'transparent';


  textArea.value = parsedText;
  document.body.appendChild(textArea);
  textArea.focus();
  textArea.select();
   
  try {
    var successful = document.execCommand('copy');
    var msg = successful ? 'successful' : 'unsuccessful';
    console.log('Copying text command was ' + msg);
  } catch (err) {
    console.log('Oops, unable to copy');
  }

 document.body.removeChild(textArea);

This code is working fine in Chrome and Firefox. Only in safari “document.execCommand(‘copy’)” method always return false and content also not copy to clipboard.

Using Unity 2021.1.5f1.

1 Like

You know this problem you should report it to Apple although I doubt they will give you an answer so they will deny everything,
so better leave your code without safari; Chrome and Firefox are fine, they are the most used.

always remember “the truth is out there”