VOOZH about

URL: https://www.geeksforgeeks.org/html/html-dom-onresize-event/

⇱ HTML DOM onresize Event - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

HTML DOM onresize Event

Last Updated : 26 Nov, 2024

The HTML DOM onresize event occurs on the browser window resize. Only the <body> tag support this event. To get the size of the window use: 

  • clientWidth, clientHeight
  • innerWidth, innerHeight
  • outerWidth, outerHeight
  • offsetWidth, offsetHeight

In HTML:

<element onresize="myScript">

In JavaScript:

object.onresize = function(){myScript};

In JavaScript, using the addEventListener() method:

object.addEventListener("resize", myScript);
Comment