将C#中的文本插入到webview-UWP中



我目前正在开发一个应用程序,在该应用程序中我使用Web视图来显示Web应用程序。我想让用户不必每次启动应用程序时都键入用户名。我想用c#中的文本自动填充Web视图中的文本框。到目前为止,我有以下代码,但我认为我的javascript还远远不够好(我对javascript没有任何具体的知识(。

private async void asyncjevoordeuser()
{
var inputValue = "test";
var functionString = string.Format(@"document.getElementById('username');", inputValue);
await WebView.InvokeScriptAsync("eval", new string[] { functionString });
}

我从调用此方法

private void WebView_LoadCompleted(object sender, NavigationEventArgs e)
{
asyncjevoordeuser();
}

我希望有人能帮我。

await WebViewObj.InvokeScriptAsync("eval", new string[] { "document.getElementById('username').value = 'username here';" }); 

最新更新