-
-
Notifications
You must be signed in to change notification settings - Fork 210
BrowserPage.setViewport()
David Ortner edited this page Jan 11, 2024
·
5 revisions
Sets the page viewport.
setViewport(viewport: IBrowserPageViewport): void;
Parameter | Type | Description |
---|---|---|
viewport | IBrowserPageViewport | Viewport object |
void
Example
import { Browser } from "happy-dom";
const browser = new Browser();
const page = browser.newPage();
page.setViewport({
width: 1920,
height: 1080,
devicePixelRatio: 2
});
// Outputs: 1920
console.log(page.mainFrame.window.innerWidth);
await browser.close();