Webbrowser mht file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • CJ

    #1

    Webbrowser mht file

    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.


  • Kalpesh

    #2
    Re: Webbrowser mht file

    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

    Comment

    • Mufaka

      #3
      Re: Webbrowser mht file

      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.

      CJ wrote:
      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.
      >
      >

      Comment

      • CJ

        #4
        Re: Webbrowser mht file

        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.


        "Mufaka" <mufaka@mufaka. comwrote in message
        news:eMDIpsceIH A.5208@TK2MSFTN GP04.phx.gbl...
        The problem is that images are loaded using subsequent requests by the web
        browser. So are javascript and css files.
        So, I think you are just going to have to write to a temp file and
        navigate to it.

        Comment

        • CJ

          #5
          Re: Webbrowser mht file

          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.

          "Kalpesh" <shahkalpesh@gm ail.comwrote in message
          news:6408994a-ca91-445e-89ee-a481aac07ea7@e6 0g2000hsh.googl egroups.com...
          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

          Comment

          • Mufaka

            #6
            Re: Webbrowser mht file

            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.


            CJ wrote:
            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.
            >
            >
            "Mufaka" <mufaka@mufaka. comwrote in message
            news:eMDIpsceIH A.5208@TK2MSFTN GP04.phx.gbl...
            >The problem is that images are loaded using subsequent requests by the web
            >browser. So are javascript and css files.
            >So, I think you are just going to have to write to a temp file and
            >navigate to it.
            >
            >

            Comment

            • CJ

              #7
              Re: Webbrowser mht file

              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.


              "Mufaka" <mufaka@mufaka. comwrote in message
              news:eS1cDbjeIH A.3400@TK2MSFTN GP03.phx.gbl...
              >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.

              Comment

              • Kalpesh

                #8
                Re: Webbrowser mht file

                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

                Comment

                • Mufaka

                  #9
                  Re: Webbrowser mht file

                  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.

                  CJ wrote:
                  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.
                  >
                  >
                  "Mufaka" <mufaka@mufaka. comwrote in message
                  news:eS1cDbjeIH A.3400@TK2MSFTN GP03.phx.gbl...
                  >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.
                  >
                  >

                  Comment

                  Working...