A brief discussion on the javascript attribute onresize

  • 2020-06-01 08:09:26
  • OfStack

A brief discussion on the javascript attribute onresize


// Gets the screen width and assigns it dynamically   
var winWidth = 0;
var winHeight = 0;
function findDimensions() // Function: gets the size 
{
// Get window width 
if (window.innerWidth)
winWidth = window.innerWidth;
else if ((document.body) && (document.body.clientWidth))
winWidth = document.body.clientWidth;
// Get window height 
if (window.innerHeight)
winHeight = window.innerHeight;
else if ((document.body) && (document.body.clientHeight))
winHeight = document.body.clientHeight;
// Through in-depth Document Within the body Detect and get the window size 
if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth)
{
winHeight = document.documentElement.clientHeight;
winWidth = document.documentElement.clientWidth;
}
// The result is output to two text boxes 

$("body").height(winHeight)
$("body").width(winWidth)
}

findDimensions();
// Call the function and get the value 
window.onresize=findDimensions;
//-->

It was only when I had to manipulate the screen size that I remembered that there was a property to manipulate the screen

The onresize event occurs when the window or frame is resized.

That's all for this article, I hope you enjoy it.


Related articles: