[JavaScript] JS获取浏览器窗口的宽度和高度 →→→→→进入此内容的聊天室

来自 , 2020-10-14, 写在 JavaScript, 查看 163 次.
URL http://www.code666.cn/view/3261769b
  1. <script type="text/javascript">
  2. <!--
  3.  
  4.  var viewportwidth;
  5.  var viewportheight;
  6.  
  7.  // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
  8.  
  9.  if (typeof window.innerWidth != 'undefined')
  10.  {
  11.       viewportwidth = window.innerWidth,
  12.       viewportheight = window.innerHeight
  13.  }
  14.  
  15. // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
  16.  
  17.  else if (typeof document.documentElement != 'undefined'
  18.      && typeof document.documentElement.clientWidth !=
  19.      'undefined' && document.documentElement.clientWidth != 0)
  20.  {
  21.        viewportwidth = document.documentElement.clientWidth,
  22.        viewportheight = document.documentElement.clientHeight
  23.  }
  24.  
  25.  // older versions of IE
  26.  
  27.  else
  28.  {
  29.        viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
  30.        viewportheight = document.getElementsByTagName('body')[0].clientHeight
  31.  }
  32. document.write('<p>Your viewport width is '+viewportwidth+'x'+viewportheight+'</p>');
  33. //-->
  34. </script>
  35. //javascript/3912

回复 "JS获取浏览器窗口的宽度和高度"

这儿你可以回复上面这条便签

captcha