-
-
Notifications
You must be signed in to change notification settings - Fork 207
DetachedWindowAPI.setViewport()
David Ortner edited this page Apr 6, 2024
·
2 revisions
Sets the page viewport.
setViewport(viewport: IBrowserPageViewport): void;
Parameter | Type | Description |
---|---|---|
viewport | IOptionalBrowserPageViewport | Viewport object |
void
Example
import { Window } from "happy-dom";
const window = new Window();
window.happyDOM.setViewport({
width: 1920,
height: 1080,
devicePixelRatio: 2
});
// Outputs: 1920
console.log(window.innerWidth);
await window.happyDOM.close();