/

HTML / CSS / JavaScript Tutorial

HTML Event attribute: onresize

[this page | pdf | back links]

The HTML onresize attribute specifies the event that is triggered when the browser window is being resized. It applies to <body> elements.

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body onresize="myOnresize()">
try resizing window
<br><br>
Window outer size: <b id="outersize"></b><br>
Window inner size: <b id="innersize"></b><br>

<script>
function myOnresize() {
  var x = window.outerWidth;
  var y = window.outerHeight;
  document.getElementById("outersize").innerHTML = x + " x " + y;
  x = window.innerWidth;
  y = window.innerHeight;
  document.getElementById("innersize").innerHTML = x + " x " + y;
}
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes


Desktop view | Switch to Mobile