mirror of
https://github.com/hanzoai/puppeteer.git
synced 2026-10-30 14:46:24 +00:00
Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Nikolay Vitkov <[email protected]>
1.1 KiB
1.1 KiB
sidebar_label
| sidebar_label |
|---|
| Page.emulateMediaType |
Page.emulateMediaType() method
Signature
class Page {
abstract emulateMediaType(type?: string): Promise<void>;
}
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
type |
string |
(Optional) Changes the CSS media type of the page. The only allowed values are |
Returns:
Promise<void>
Example
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