I'm trying to display the window size, whenever I resize my window. but I'm not able to until I refresh the window, I want to see the window size on the fly while I'm resizing the window.
window.onload = init();
window.onresize = init();
function init() {
  var status = document.querySelector("#pagesize");
  status.innerHTML = "" + window.innerHeight + " " + window.innerWidth;
}
#pagesize {
  border: 1px solid red;
  padding: 2px;
  color: red;
}
html code:-
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <link rel="stylesheet" href="style.css">
  <title>window resize</title>
</head>
<body>
  <p>PAGE WINDOW SIZE <span id="pagesize">NOT LOADED YET</span></p>
  <script src="script.js"></script>
</body>
</html>