# Add event listener on page resize

> There is a special event listener in javascript that is called whenever a page resize is detected. The event listener is named 'resize' and can be used in…

- URL: https://graffino.com/til/add-event-listener-on-page-resize
- Author: Mihai Barbu
- Channel: javascript
- Published: 2021-12-08
- Updated: 2021-12-08

There is a special event listener in javascript that is called whenever a page resize is detected. The event listener is named 'resize' and can be used in the following way:

```
function onFrameResize(){
  console.table(
    {
      Height: window.innerHeight,
      Width: window.innerWidth  
    }
  );
}

window.addEventListener("resize", onFrameResize);
```

"window.innerHeight" and "window.innerWidth" are functions to access the width and the height of the frame.

This functionality will come in handy when working with responsive components.
