【问题标题】:HTML Injection Windows RT WebViewHTML 注入 Windows RT WebView
【发布时间】:2015-10-21 09:46:36
【问题描述】:

我正在尝试将值插入到我的 Windows 通用应用程序上的 HTML 文档中,该 HTML 文档位于 Web 服务器上,并且我正在尝试插入保存在客户端设备 Winphone 或 PC Store 应用程序上的用户名和密码,我知道 id 和有关元素的所有信息,但我不知道如何将字符串插入输入值,有人可以提供 InvokeScript("smth", new string[] {smthelse});

的示例

或者有更好的办法将用户名和密码插入到 webview 的 HTML 内容中?

我被困在这里,我真的需要这个功能。

提前致谢

【问题讨论】:

    标签: javascript html webview windows-runtime windows-store-apps


    【解决方案1】:

    将下面的代码添加到您的 XAML 中并试一试。如果您知道 ID,则可以通过向页面中注入一些脚本来设置其值。

    private async void Button_Click(object sender, RoutedEventArgs e)
    {
        string functionString = String.Format("document.getElementById('nameDiv').innerText = 'Hello, {0}';", nameTextBox.Text);
        await webView1.InvokeScriptAsync("eval", new string[] { functionString });
    }
    

    别调皮。坦帕的希利。

    【讨论】:

      猜你喜欢
      • 2017-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多