I cannot find any information on how to insert links into MHTML files.
I have a local MHTML file (the file was generated by Chrome). It contains the following code:
<a href=3D"file:///C:/dir1/file=
1.mhtml" target=3D"_self">link to C:/dir1/file1.mhtml</a>
When I click this link, I want the browser (Chrome) to visit the file whose URL is file:///C:/dir1/file1.mhtml
. But if I click the link, nothing happens. The browser does not react. Why? If I place the cursor over the link text, copy link address, then paste it into the URL bar and press Enter
, the browser loads the page as expected.
But if I click the link, nothing happens
Something happens: errors on web console
When opening the mhtml file
test.mhtml:1 Not allowed to load local resource: file:///home/lmc/tmp/test.mhtml
test.mhtml:1 Blocked script execution in 'file:///home/lmc/tmp/test.mhtml' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
When clicking the link (or Ctrl + click)
test.mhtml:1 Not allowed to load local resource: file:///home/lmc/tmp/test2.mhtml
Errors appear even running chrome as
chromium-browser --allow-file-access-from-files
Open the link with:
Right click -> Open link in new tab
or grabbing the link and using drag-and-drop action over the same tab name or empty space to the right of the last tab.
Note: current chrome does not allow to save a page as mhtml
unless started as
chromium-browser --save-page-as-mhtml
Given this html
<html>
<body>
<a href="file:///home/lmc/tmp/test2.mhtml">a tmp file</a><br>
<a href="javascript:alert('pwn3d!')">a javascript</a>
</body>
</html>
It will be saved by chrome with the javascript protocol removed
From: <Saved by Blink>
Snapshot-Content-Location: file:///home/lmc/tmp/test.html
Subject:
Date: Thu, 5 Jun 2025 19:36:49 -0300
MIME-Version: 1.0
Content-Type: multipart/related;
type="text/html";
boundary="----MultipartBoundary--fIf6o9C0OBJBw2dUX03CEHpSzIQPbDIprfIniq0dLF----"
------MultipartBoundary--fIf6o9C0OBJBw2dUX03CEHpSzIQPbDIprfIniq0dLF----
Content-Type: text/html
Content-ID: <frame-0192AA76249CA62FB44F372B0620B953@mhtml.blink>
Content-Transfer-Encoding: quoted-printable
Content-Location: file:///home/lmc/tmp/test.html
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; charset=
=3Dwindows-1252"></head><body>
<a href=3D"file:///home/lmc/tmp/test2.mhtml">a tmp file</a><br>
<a>a javascript</a>
=20
</body></html>
------MultipartBoundary--fIf6o9C0OBJBw2dUX03CEHpSzIQPbDIprfIniq0dLF------