Reputation: 10143
I'm using CefSharp for showing a html file in CefSharp browser
.
when I use web_view.Load(@"C:\htmlfile.htm");
it's show my body background.
but when i load htmlfile.htm
and use web_view.LoadHtml(File.ReadAllText(@"C:\in.htm"));
body background doesn't show?
I want to ask how do i must set address body background in html local file?
This is My Html File content:
<html>
<body background="C:\Untitled.png">
</body>
</html>
Upvotes: 2
Views: 4450
Reputation: 9063
Another way you could do this is use a schemeHandler (it's cleaner IMO).
CEF.RegisterScheme("ascheme", new HandlerFactory());
Add a scheme handler that loads the PNG from disk and returns a relevant response
then change your html to refer to the scheme:
body background="myscheme://Untitled.png"
I can fill in the blanks if need be... but that should be enough!
Upvotes: 0
Reputation: 61
Try this:
web_view.LoadHtml(File.ReadAllText(@"C:\in.htm"), @"C:\in.htm");
The second parameters indicates the URL, if the URL is a local resource then, the page will be able to load local resources.
Upvotes: 6
Reputation: 41088
You will have to implement IRequestHandler.OnBeforeResourceLoad()
, intercept each request, and read the bytes yourself from disk and suppy them to chromium as a response.
https://github.com/chillitom/CefSharp/blob/master/CefSharp/IRequestHandler.h#L26
Upvotes: 0