Closed limingzxf closed 4 months ago
async function copyTextToClipboard(textToCopy) { try { if (navigator?.clipboard?.writeText) { await navigator.clipboard.writeText(textToCopy); } } catch (err) { alert(err); } } copyTextToClipboard(res)
will alert "write persimmon denied"
i try const { clipboard } = cordova.plugins; clipboard.copy("res"); still not working
I want to use webview to inject js, but it seems impossible it have many bug
This doesn't appear to be a bug with the in-app browser plugin.
Using executeScript
to trigger paste commands, either via the deprecated execCommand
or the newer Clipboard API likely won't work because they need to be triggered from a trusted user event. E.g. the code needs to run as part of a user-initiated device on the DOM. Injected javascript is not considered a secure source in the DOM context.
thanks, I would use another injection tool, or give up
function legacyCopy(value) { alert(66) const ta = document.createElement('textarea') ta.value = value ?? '' ta.style.position = 'absolute' ta.style.opacity = '0' document.body.appendChild(ta) ta.select() document.execCommand('copy') ta.remove() alert(76) } legacyCopy("res") will alert 66 and 76,but not write to clipboard