Welcome What's new in Chrome extensions API reference Samples
Welcome What's new in Chrome extensions API reference Samples

chrome.pageCapture

  • Description

    Use the chrome.pageCapture API to save a tab as MHTML.

  • Permissions
    pageCapture
    This permission triggers a warning.

MHTML is a standard format supported by most browsers. It encapsulates in a single file a page and all its resources (CSS files, images..).

Note that for security reasons a MHTML file can only be loaded from the file system and that it can only be loaded in the main frame.

Manifest

You must declare the "pageCapture" permission in the extension manifest to use the pageCapture API. For example:

{
"name": "My extension",
...
"permissions": [
"pageCapture"
],
...
}

Summary

Methods

saveAsMHTML

chrome.pageCapture.saveAsMHTML(
  details: object,
  callback?: function,
)
Promise

Saves the content of the tab with given id as MHTML.

Parameters

  • details

    object

    • tabId

      number

      The id of the tab to save as MHTML.

  • callback

    function optional

    The callback parameter looks like: (mhtmlData?: ArrayBuffer) => void

    • mhtmlData

      ArrayBuffer optional

      The MHTML data as a Blob.

Returns

  • Promise<ArrayBuffer | undefined>

    Chrome 116+

    Promises are supported in Manifest V3 and later, but callbacks are provided for backward compatibility. You cannot use both on the same function call. The promise resolves with the same type that is passed to the callback.

This site uses cookies to deliver and enhance the quality of its services and to analyze traffic. If you agree, cookies are also used to serve advertising and to personalize the content and advertisements that you see. Learn more about our use of cookies.