title: Custom functions unavailable from BrowserInteropHelper.HostScript in an XBAP
body: <p>I'm attempting to use an XBAP to acquire TWAIN Images but I'm not even getting that far. I can't seem to get the BrowserInteropHelper.HostScript to allow me to talk back to the javascript on the host page.</p>
  
  <ul>
  <li>I am running the XBAP in an iframe.</li>
  <li>I tried full trust (even though that should be a requirement).</li>
  <li>I'm testing on IE9, .NET Framework 4.0</li>
  <li>The BrowserInteropHelper.HostScript is not null, I can use the normal window methods, like .Close().</li>
  </ul>
  
  <p>My code looks like this:</p>
  
  <h2>Index.html:</h2>
  
  <pre><code>&lt;p id="someP"&gt;My cat's breath smells like cat food.&lt;/p&gt;
  
  &lt;script type="text/javascript"&gt;
      function WorkDamnit() {
          $('#someP').hide();
      }
  &lt;/script&gt;
  
  &lt;iframe src="@Url.Content("~/XBAPs/WPFBrowserApplication1.xbap")" style="border: none;" width="500" height="500" /&gt;
  </code></pre>
  
  <h2>Page1.xaml.cs:</h2>
  
  <pre><code>private void Button_Click(object sender, RoutedEventArgs e)
  {
      if (BrowserInteropHelper.HostScript == null)
          throw new ApplicationException("hostscript is null");
      else
          BrowserInteropHelper.HostScript.WorkDamnit();
  }
  </code></pre>
  
  <h2>I get:</h2>
  
  <pre><code>System.MissingMethodException: Method '[object Window].WorkDamnit' not found.
  </code></pre>
  
  <h2>New Info:</h2>
  
  <p>This scenario works properly from other PCs on the network and I found out why. IE9 has a setting turned on by default called "Display intranet sites in Compatibility View". This causes the page to render in "IE7 mode" and the javascript function is available from the XBAP. If I click Document Mode: (under the F12 developer tools console) and switch to IE9 mode then it no longer works (as above). On my own PC it uses IE9 mode by default (As it should) and it does not work unless I manually switch to IE7 mode.</p>