Search code examples
htmlgoogle-chromehyperlinkmhtml

How to create MHTML standalone file with same page links


How do you export an MHTML standalone webpage from google chrome that has correctly operating same page links?

For instance, download this working example and open it in Chrome from your local machine:

<!DOCTYPE html>
<html>
<body>

<p>
<a href="#C4">See also Chapter 4.</a>
</p>

<h2>Chapter 1</h2>
<p>This chapter explains ba bla bla</p>

<h2>Chapter 2</h2>
<p>This chapter explains ba bla bla</p>

<h2>Chapter 3</h2>
<p>This chapter explains ba bla bla</p>

<h2><a id="C4">Chapter 4</a></h2>
<p>This chapter explains ba bla bla</p>

</body>
</html>

Now save it as an MHTML file and try opening that MHTML version from your local machine. The hyperlink does not respond to a left mouse click.

However, the link will work if you:

  • manually type the hyperlink into the address bar: file:///C:/Users/usr/Desktop/test.html#C4

  • right click on the hyperlink and select "open in new tab"

So clearly the link still exists, which is further evidenced by hovering over it:

enter image description here

So why can't a left mouse click trigger the hyperlink like it did for the .html version?

This problem doesn't seem to exist for IE (at least for this example) and I have chrome Version 35.0.1916.114 m. It would be nice to know a general, platform independent solution to not restrict which browser is used to open the MHTML


Solution

  • I use singlefile, a chrome extension found on the Chrome store, it produces MHTML files

    https://chrome.google.com/webstore/detail/singlefile/mpiodijhokgodhhofbcjdecpffjipkle