Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Go to Latest
method Page.prototype.emulateMediaType
import { Page } from "https://deno.land/x/puppeteer@14.1.1/vendor/puppeteer-core/puppeteer/common/Page.js";

Examples

Example 1

await page.evaluate(() => matchMedia('screen').matches);
// → true
await page.evaluate(() => matchMedia('print').matches);
// → false

await page.emulateMediaType('print');
await page.evaluate(() => matchMedia('screen').matches);
// → false
await page.evaluate(() => matchMedia('print').matches);
// → true

await page.emulateMediaType(null);
await page.evaluate(() => matchMedia('screen').matches);
// → true
await page.evaluate(() => matchMedia('print').matches);
// → false

Parameters

optional
type: string
  • Changes the CSS media type of the page. The only allowed values are screen, print and null. Passing null disables CSS media emulation.

Returns

Promise<void>