sidebar_label |
---|
Page.emulateMediaType |
class Page {
abstract emulateMediaType(type?: string): Promise<void>;
}
Parameter |
Type |
Description |
---|---|---|
type |
string |
(Optional) Changes the CSS media type of the page. The only allowed values are |
Promise<void>
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