iFrame blocks copy to clipboard | Community
Skip to main content

iFrame blocks copy to clipboard

  • August 17, 2022
  • 3 replies
  • 0 views

Working on a ticket sidebar application and currently have a button that triggers a copy of a link to the clipboard. When run inside the sidebar application we are getting the errror:

"document.requestStorageAccess() may not be called in a sandboxed iframe without allow-storage-access-by-user-activation in its sandbox attribute"

Is there a way to add these sandbox iframe attributes with the manifest.json file or a way around this by using verified urls etc?

3 replies

Eric27
  • August 18, 2022
Hey Luke,

Can you provide a code snippet so we can see how you're trying to accomplish this? 
 
Thanks!

  • Author
  • August 25, 2022

Sure thing, I am trying to copy text to the clipboard using this function:

function executeCopy(text) {
// create input to insert text into
var input = document.createElement('textarea');
document.body.appendChild(input);
input.value = text;

// focus and highlight text
// input.focus();
input.select();

// copy the text
document.execCommand('Copy');

// remove unneeded input
//input.remove();

// notify user
alert('Copied to clipboard');
}

Tipene
  • August 26, 2022
Hey Luke,
 
I haven’t been able to replicate the issue you’re seeing in Google Chrome. After doing a bit of digging, it appears that this is an issue specific to the Firefox browser.
 
Can you try running the app in Google Chrome and see if everything runs correctly there?
 
Thanks,
 
Tipene