简体   繁体   English

如何将WebView中的数据存储在localdata UWP中

[英]How to store data from webview in localdata UWP

For my app I want to store the usernames that are entered into the local appdata. 对于我的应用程序,我想存储在本地应用程序数据中输入的用户名。 I do not know how to store the value that is entered in the textbox from the webview to the localdata. 我不知道如何存储从Web视图到本地数据的文本框中输入的值。 Looking across the internet I also could not find any right answer. 从互联网上看,我也找不到任何正确的答案。

I have read InvokeScriptAsync is a method that is used for this kind of things but there's not instruction on how to use it in my case. 我已经读过InvokeScriptAsync是用于此类事情的一种方法,但是在我的情况下没有关于如何使用它的说明。

I hope someone will have a solution for me. 我希望有人能为我解决。

Thanks in advance! 提前致谢!

You can use InvokeScriptAsync to both inject javascript and retrieve html from WebView . 您可以使用InvokeScriptAsync注入javascript并从WebView检索html。

Here is the code to retrieve text entered by user in the WebView. 这是用于检索用户在WebView中输入的文本的代码。 Let consider username is the id of html input field and you want to retrieve what ever the text entered into that input by user. 让我们考虑用户名是html输入字段的ID,您想检索用户输入到该输入中的文本。

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

This should called on NavigationCompleted callback method of WebView. 这应该在WebView的NavigationCompleted回调方法上调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM