Hello,
Welcome to our Microsoft Q&A platform!
In WebView
, there is no API to disable user-web page interaction.
But we can inject Javascript to add a layer of invisible mask to Html document to prevent user interaction.
We can listen to the WebView.LoadCompleted
event and perform the following processing:
private async void WebView_LoadCompleted(object sender, NavigationEventArgs e)
{
var webView = sender as WebView;
var height = await webView.InvokeScriptAsync("eval", new string[] { "document.body.scrollHeight.toString()" });
string script = "var body=document.body;" +
"var temp = document.createElement('div'); " +
$"temp.style=\"height:{height}px; width:100%; background:transparent;position:absolute;top:0;left:0;z-index:9999;\";" +
"body.appendChild(temp)";
await webView.InvokeScriptAsync("eval", new string[]
{
script
});
}
Thanks.