|
Rank: Member Groups: Member
Joined: 11/4/2014 Posts: 12
|
Hi, we're interested in using your webview to render locally (file system) stored website content that will be built into the deployed end product. At the moment we are experimenting with the tabbed browser sample and we can't figure out how to get an <img> tag correctly processed if we add a line into the EmbeddedPage.htm file. Can you advise on the syntax to use in the htm file and the file location in the project folder where we'll need to place the image. Thanks. (EO.WebBrowser version=3.0.100.0)
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,273
|
Hi, There are two ways to do this. The first way is to add the following code before you creating any WebView:
Code: C#
//Set the default option to turn off web security
EO.WebBrowser.BrowserOptions options = new EO.WebBrowser.BrowserOptions();
options.EnableWebSecurity = false;
EO.WebBrowser.Runtime.SetDefaultOptions(options);
The second way is to use a fake file Url instead of a custom protocol. For example, instead of loading "sample://embedded_page", you can load "file://c:/this_file_does_not_exist.html". You would then check to match this Url and handle this Url in your custom resource handler. Once you handle this Url in your custom resource handler, the browser engine would consider this Url handled and won't go further to look for the actual physical file. The root of the problem is the same origin security policy imposed by all modern browsers. By default the "sample://embedded_page" is considered to be a Url on the Internet, as such it is not allowed to access a local file on your own machine. Thus the solution is to either turn this security policy off (method #1), or to satisfy this rule by making them to be the same origin (method #2). Hope this helps. Please feel free to let us know if you have any more questions. Thanks!
|
|
Rank: Member Groups: Member
Joined: 11/4/2014 Posts: 12
|
Hi, Thanks for the quick reply. We'll give this a go. I don't suppose you have a small sample project illustrating this by any chance? :-)
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,273
|
Hi,
If you use method #1, all you need to do is to copy the above code and paste it into App.xml.cs before creating the main window. After that you can add local img elements into EmbeddedPage.html and it should work.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 11/4/2014 Posts: 12
|
Hi, Yep that's works well :-) Thanks for the great support!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,273
|
Great! Glad to hear that it works for you!
|
|