Search code examples
javascripthtml.netdotnetbrowser

Loading a local HTML page with embedded javascript files DotNetBrowser


I am looking through the samples and I have yet to come across an example of loading a local HTML file that contains embedded JavaScript inside it. Something like, along with several others for the project on the main index.html page.

<script>src="angular.js"</script>

I am sure there must be a way to accomplish this, similar to how you could do it in CefSharp, where I got it working fairly quickly(unfortunately it was extremely memory intensive which was not going to work).

Basically I want to load the HTML file similarly to how one would do it in ASP.Net but without actually having to have a server, just read the file off the disk and load it into the DotNetBrowser along with any scripts it needs to load that are on the page.

I loaded it up and went into the debugging window and it appears to have loaded a lot of the scripts, but angular didn't load and it threw an error about chrome.app extensions not being available.

from the debugger Any help would be greatly appreciated.


Solution

  • It is necessary to disable web security and allow file access for DotNetBrowser. This can be done via the Chromium command-line switches. The following article explains how to pass these switches to DotNetBrowser:

    http://dotnetbrowser-support.teamdev.com/documentation/chromium-switches

    The --disable-web-security and --allow-file-access-from-files switches will turn off the same-origin policy and allow file access from HTML.