Webbrowser mht file

C

CJ

After you trigger your event and store an internet webpage as an .mht file,
then you store the contents of the .mht into a database. Has anyone figured
out how to load the contents from the db into a webbrowser, and have it
display the same way with all the embedded pictures and everything?

I have been reading posts for days, but it seems there is no answer to this
question.

If you download a webpage into an .mht file and you double-click on the
file, it opens up fine in IE. But what is the trick in getting it to
display the
same way from a string, or a blob stream from a db.
 
K

Kalpesh

Note: I have not worked with mht files & loading them programatically
from database/string.
However, it is just a file

So, if you have stored it in a db, you can retrieve the content in
form of a string.
Create a temporary mht file with those contents on your filesystem &
open that file using Process.start <path to the mht file>

Does that help?

Kalpesh
 
M

Mufaka

The problem is that images are loaded using subsequent requests by the
web browser. So are javascript and css files.

IE knows how to handle these subsequent requests by using a different
protocol to fetch the named resource from the mht file.

For example, viewing the properties on an image gives me the following:

mhtml:file://C:\Temp\Google.mht!http://www.google.com/intl/en_ALL/images/logo.gif

So, I think you are just going to have to write to a temp file and
navigate to it.
 
C

CJ

I wish it worked like that, but it does not. Once you change the file
extension from
..mht to anything else, guess what it does not work. It has to have an .mht
file
extension for it to work. I tried it and was truly disappointed at the
results.
I have seen other programs save and load the entire page from a database,
but I have no clue on how they are doing it.
 
C

CJ

Kalpesh,

Doing it like that will work, but I really would like to display it from the
db and not by creating
and deleting a temp file.
 
M

Mufaka

I don't think I suggested that you change the file extension. Perhaps I
wasn't clear enough.

You are *probably* never going to be able to render the web page
straight from the database if it is in mht format or contains images, js
files, or css files.

The rendering of html will make additional requests for images, js
files, and css files. If you don't have somewhere to fetch those that
the browser can get to, it won't work.
 
C

CJ

Is there such a thing as rendering the images inline and store them into the
html file?

Something like a resource file that stores everything in gibberish, but when
you
load it, you can see the pictures etc.
 
K

Kalpesh

From what I understand, it will require a file to be shown in the
browser.
It could be a case where the browser hosted inside the application
doesn't show the address bar.

Try using process explorer to see what files are opened by the
application.

Kalpesh
 
M

Mufaka

Not that I know of. MHT is pretty good if you can get past not wanting
to have it read from a local file.

I understand that you don't want to have to manage those files, but you
might also want to consider that you are probably going to want some
caching mechanism for these anyways depending on your database.

Also, consider that if you use Navigate, you will be able to use the
built in Back/Forward to page through previously loaded pages.

It doesn't seem too terrible to have an application folder sub-directory
to write these files from the database. When the application fetches an
mht from the database, it can create the directory if needed and write
the file there. When the application exits, it can just remove the
directory.

Another approach might be to tackle this from the MIME perspective. You
can parse these files with a MIME parser so you may be able to figure
out how email clients render emails with html bodies.

Regardless, when I come across situations like these, I typically use an
approach that I know how to get working and move on. I create an
Interface for it where I can easily swap out the behavior with another
implementation if a better solution can be found.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top