title: How to invoke javascript in WebView Windows 10 UWP?
body: <p>I am trying to load a javascript in WebView to do some calculations and get the output in a string. I tried to use following code</p>
  
  <pre><code>string htmlFragment = "&lt;html&gt;&lt;head&gt;&lt;script type='text/javascript'&gt;" +
                      "function doubleIt(incoming){ " +
                      "  var intIncoming = parseInt(incoming, 10);" +
                      "  var doubled = intIncoming * 2;" +
                      "  document.body.style.fontSize= doubled.toString() + 'px';" +
                      "  return doubled.toString());" +
                      "};" +
                      "&lt;/script&gt;&lt;/head&gt;&lt;body&gt;" +
                      "&lt;div id = 'myDiv'&gt;I AM CONTENT&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;";
              htmlView.NavigateToString(htmlFragment);
              htmlView.LoadCompleted += async(s1,e1) =&gt;
                {
                    string result = await htmlView.InvokeScriptAsync("eval", new string[] { "doubleIt(25)" });
                    Debug.WriteLine(result);
                };
  </code></pre>
  
  <p><strong>Update</strong>
  I am able to load simple javascript easily now based on help provided in the answer. But now I am facing issues when there is more than one function in javascript, I am getting an exception. I am trying the following code</p>
  
  <pre><code>string htmlFragment = @"&lt;html&gt;&lt;head&gt;&lt;script type='text/javascript'&gt;" +
                      "function a(){return 10;};" +
                      "function b(){return 20;};" +
                      "function c(){return 30;};" +
                      "return (a()*b()*c());" +
                      "&lt;/script&gt;&lt;/head&gt;&lt;body&gt;" +
                      "&lt;div id = 'myDiv'&gt;I AM CONTENT&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;";
  </code></pre>
  
  <p>Please suggest.</p>