Can anyone shed any light on WebViewDOMContentLoadedEventArgs? RRS feed

  • Question

  • I want to retrieve the HTMLDocument object or interface in a WebView, so I can access and edit the DOM element in it. I've not found the Document or Content(or something like it) property on WebView class. The best chance, I guess, that I can get it is in the DOMContentLoaded event. The event handler has a parameter of type WebViewDOMContentLoadedEventArgs, and it has a property named Uri.

            void MyWebView_DOMContentLoaded(WebView sender, WebViewDOMContentLoadedEventArgs args)
    And this property is interpreted as "the URI of the content". My question is: What does this mean? Does it mean that the Uri is the HtmlDocument of WebView? What type should I cast it to? Any idea would be appreciated!

    Friday, November 22, 2013 10:03 AM


All replies

  • Hi,

    You can invoke Javascript inside the displayed webpage of a Webview to access and edit the DOM element in it. Invoking JavaScript functions in WebView-hosted content from your app code by calling the InvokeScript method. In windows 8.1, Use InvokeScriptAsync instead.

    Try to refer to the Matt's blog see how to invoke javascript in webview:


    And you can see the sample below:


    Best Wishes!

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Edited by Anne Jing Monday, November 25, 2013 5:18 AM edit
    • Marked as answer by silverbird.lee Monday, November 25, 2013 11:59 AM
    Monday, November 25, 2013 5:05 AM
  • Hi, Anne, thanks for your detailed answer!

    I've tried InvokeScriptAsync() method, it works great. And these two links you recommended are very helpful too. You're very kind, many thanks!

    Monday, November 25, 2013 11:58 AM