title: WebView.InvokeScriptAsync not working in universal app
body: <p>I am using a webview to display a certain html file, However, when I call InvokeScriptAsync, I keep encountering the error.
  <strong>"Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME))".</strong> This occurs eventhough the script is called in NavigationComplete or DOMContentLoaded.</p>
  
  <p>I prepared a simple app to debug this problem and <strong>I noticed that when the script is in a separate .js file, the error occurs. But if it is placed in the html file, the error would not occur.</strong></p>
  
  <p>I am hoping to have the script in a separate file since I have a quite a lot of functions to implement and I would be using some third party scripts so it would not be maintainable having all the scripts on the html file.</p>
  
  <p>BTW, I did try the same code in a non-universal app and just used Windows 8.1 store app and it would work correctly even with the script stored in a separate file. That is why there must be some setting I am missing to make this work in a universal app.</p>
  
  <p><strong>This is my MainPage code:</strong></p>
  
  <pre><code>public sealed partial class MainPage : Page
  
  {
  
      public MainPage()
      {
          this.InitializeComponent();
          MapWebView.NavigationCompleted +=MapWebView_NavigationCompleted;
      }
  
      protected override void OnNavigatedTo(NavigationEventArgs e)
      {
              Uri url = new Uri("ms-appx-web:///Common/Web/SamplePage.html");
              MapWebView.Navigate(url);
      }
  
      private async void MapWebView_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
      {
          try
          {
               await MapWebView.InvokeScriptAsync("SayHello", new string[] { "Hello! This is a test parameter" });
          }
          catch(Exception e)
          {
              string error = e.Message;
          }
      }
  }
  </code></pre>
  
  <p><strong>NOT WORKING (script is in a separate file which is sample.js):</strong>
  <strong>html file:</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
      &lt;html lang="en" xmlns="http://www.w3.org/1999/xhtml"&gt;
      &lt;head&gt;
          &lt;meta charset="utf-8" /&gt;
          &lt;title&gt;&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;script type="text/javascript" src="sample.js"&gt;&lt;/script&gt;
          &lt;p&gt;Parameter From Script File:&lt;/p&gt; &lt;div id="paramDiv"&gt;&lt;/div&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p><strong>sample.js file:</strong></p>
  
  <pre><code>function SayHello(parameter) 
  {
      document.getElementById('paramDiv').innerHTML = parameter;
  }
  </code></pre>
  
  <p><strong>WORKING (script is in the html file):</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
      &lt;html lang="en" xmlns="http://www.w3.org/1999/xhtml"&gt;
      &lt;head&gt;
          &lt;meta charset="utf-8" /&gt;
          &lt;title&gt;&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;script&gt;
              function SayHello(parameter) {
                  document.getElementById('paramDiv').innerHTML = parameter;
              }
          &lt;/script&gt;
          &lt;p&gt;Parameter From Script File:&lt;/p&gt; &lt;div id="paramDiv"&gt;&lt;/div&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p><strong>Here is the setup of my project:</strong>
  I have my project setup as a universal app. In the shared code part of the universal app, I have the following files</p>
  
  <ul>
  <li>Common (folder)
  
  <ul>
  <li>Web
  
  <ul>
  <li>SamplePage.html</li>
  <li>sample.js</li>
  </ul></li>
  </ul></li>
  </ul>