Hello,@Kyle W
Welcome to Microsoft Q&A!
We are still trying to solve the problem of clipboard API, we first provide a solution to the current problem.
Use window.document.execcommand('copy') in javascript.
private async void myButton_Click(object sender, RoutedEventArgs e)
{
string text = System.IO.File.ReadAllText(@"C:\**\****\***\Untitled-1.js");
var res = await webView.ExecuteScriptAsync(text);
}
The javascript related content is below.
document.featurePolicy.allowedFeatures();
const span = document.createelement('span')
let text = document.body.innertext;
span.textcontent = text
span.style.whiteSpace = 'pre'
// Put <span> into the page
document.body.appendchild(span)
const selection = window.getselection()
const range = window.document.createrange()
selection.removeallranges()
range.selectnode(span)
selection.addrange(range)
// Copy text to clipboard
let success = false
try {
success = window.document.execcommand('copy')
} catch (err) {
console.log('error', err)
}
selection.removeallranges()
window.document.body.removechild(span)
211897-untitled-1.txt
Thank you.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.