//获取屏幕宽度并动态赋值    
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;
//-->

只有我要对屏幕大小进行操作的时候才想起原来还有个对屏幕操作的属性

onresize 事件会在窗口或框架被调整大小时发生。

 

相关文章:

  • 2021-12-10
  • 2022-12-23
  • 2022-12-23
  • 2022-03-02
  • 2021-11-23
  • 2021-05-25
  • 2021-08-23
  • 2022-12-23
猜你喜欢
  • 2022-01-06
  • 2021-06-01
  • 2021-10-06
  • 2022-01-04
  • 2021-12-20
  • 2021-10-23
  • 2021-05-16
相关资源
相似解决方案