JS兼容方式获取浏览器的宽度
<script type="text/javascript"> //need to wait until onload so body is available window.onload = function(){ function getWindowWidth(){ if (window.innerWidth){ return window.innerWidth; } else if (document.documentElement.clientWidth){ return document.documentElement.clientWidth; } else if (document.body.clientWidth){ return document.body.clientWidth; } } //determine if the browser has Netscape-style plugins var hasNSPlugins = !!(navigator.plugins && navigator.plugins.length); //determine if the browser has basic DOM Level 1 capabilities var hasDOM1 = !!(document.getElementById && document.createElement && document.getElementsByTagName); alert("Window width: " + getWindowWidth()); alert("Supports Netscape plugins? " + hasNSPlugins); alert("Supports Core DOM 1? " + hasDOM1); } </script>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。