Skip to content

Commit

Permalink
#592@patch: Updates the documentation for how to set window.innerWidt…
Browse files Browse the repository at this point in the history
…h and window.innerHeight.
  • Loading branch information
capricorn86 committed Oct 6, 2022
1 parent f472943 commit 540ac3a
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions packages/happy-dom/README.md
Expand Up @@ -84,11 +84,13 @@ The default Window class is a [VM context](https://nodejs.org/api/vm.html#vm_vm_
```javascript
import { Window } from 'happy-dom';

const window = new Window();
const window = new Window({
innerWidth: 1024,
innerHeight: 768,
url: 'http://localhost:8080
});
const document = window.document;
window.location.href = 'http://localhost:8080';

document.write(`
<html>
<head>
Expand Down Expand Up @@ -143,11 +145,13 @@ The example below will show you how to setup a Node [VM context](https://nodejs.
```javascript
import { Window } from 'happy-dom';
const window = new Window();
const window = new Window({
innerWidth: 1024,
innerHeight: 768,
url: 'http://localhost:8080
});
const document = window.document;

window.location.href = 'http://localhost:8080';

document.write(`
<html>
<head>
Expand Down Expand Up @@ -230,6 +234,22 @@ window.setTimeout(() => {
window.happyDOM.cancelAsync();
```

**setInnerWidth()**

Sets the property `window.innerWidth` and dispatches a "resize" event.

```javascript
window.happyDOM.setInnerWidth(1024);
```

**setInnerHeight()**

Sets the property `window.innerHeight` and dispatches a "resize" event.

```javascript
window.happyDOM.setInnerHeight(768);
```



# Performance
Expand Down

0 comments on commit 540ac3a

Please sign in to comment.