locked
Webview DOMContentLoaded behavior

    Question

  • I have a webview with scriptnotify

     async void MyWebview_ScriptNotify_1(object sender, NotifyEventArgs e)
            {
                var p = e.Value;
                if (p == "next")
                  { 
                    ............
                   webView1.DOMContentLoaded += (s, a) => webView1.InvokeScriptAsync("getlast", new string[] { p });
                   }
    	     else  if (p == "previous")
                  { 
                    ............
                   webView1.DOMContentLoaded += (s, a) => webView1.InvokeScriptAsync("getlast", new string[] { p });
                   }
       }

    and in my JavaScript function I do check if value passed is = "previous" do whatever I want otherwise do nothing.

    I need to invoke the script after webview content was loaded only when scriptnotify fires "previous". So I did pass the p value which is e.value of scriptnotify. But when debugging I noticed that when p = "next"  DOMContentLoaded  fires the script with "previous" value and not with the actual value of the variable p.

    What is wrong? How can I achieve that?

    Tuesday, May 13, 2014 10:52 AM

All replies

  • Well, the code looks right from here. Do you have a reproduction app you can post?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, May 13, 2014 7:06 PM
    Moderator