Home >Web Front-end >JS Tutorial >A brief discussion on javascript attribute onresize_javascript skills

A brief discussion on javascript attribute onresize_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:03:011750browse

A brief discussion on the javascript attribute onresize

//获取屏幕宽度并动态赋值  
var winWidth = 0;
var winHeight = 0;
function findDimensions() //函数:获取尺寸
{
//获取窗口宽度
if (window.innerWidth)
winWidth = window.innerWidth;
else if ((document.body) && (document.body.clientWidth))
winWidth = document.body.clientWidth;
//获取窗口高度
if (window.innerHeight)
winHeight = window.innerHeight;
else if ((document.body) && (document.body.clientHeight))
winHeight = document.body.clientHeight;
//通过深入Document内部对body进行检测,获取窗口大小
if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth)
{
winHeight = document.documentElement.clientHeight;
winWidth = document.documentElement.clientWidth;
}
//结果输出至两个文本框

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

findDimensions();
//调用函数,获取数值
window.onresize=findDimensions;
//-->

Only when I want to manipulate the screen size, I remember that there is an attribute for screen manipulation

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

The above is the entire content of this article, I hope you all like it.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn