locked
How to use Webview in Accessing Dom in winrt App

    Question

  • I am working in Metro App were i need to use Webview that can access the DOM to send value to certain elements of a website, such as textbox for that i have to get the element id from the DOM page of text box so that i can send value to the element just like it is done in webbrowser element below

    WebBrowser1.Document.GetElementById("youtube-url").SetAttribute("value", TextBox1.Text);
    WebBrowser1.Document.GetElementById("submit").InvokeMember("click");
    Button3.Enabled = true;

    Is there any way that this problem can be solved through WebView or there is any way to Solve this problem in winrt.


    • Edited by ishan1.2 Monday, November 03, 2014 11:25 AM To make it more Clear
    Monday, November 03, 2014 11:21 AM

Answers

  •        async private void webview_DOMContentLoaded(WebView sender, WebViewDOMContentLoadedEventArgs args)
            {
                string[] command = { "document.title;" };
                string result = await webview.InvokeScriptAsync("eval", command);
                Debug.WriteLine(result);
            }
    And refer to this sample code in MSDN Code Gallery: XAML WebView control Sample.

    在現實生活中,你和誰在一起的確很重要,甚至能改變你的成長軌跡,決定你的人生成敗。 和什麼樣的人在一起,就會有什麼樣的人生。 和勤奮的人在一起,你不會懶惰; 和積極的人在一起,你不會消沈; 與智者同行,你會不同凡響; 與高人為伍,你能登上巔峰。

    Monday, November 03, 2014 4:56 PM