我听说这是偏移宽度 https://stackoverflow.com/questions/833699/clientheight-clientwidth-returning-different-values-on-different-browsers/2334106#2334106、 document.documentElement.clientWidth 和 window.innerWidth
我很好奇无法使用 jQuery 的项目,我应该使用哪种解决方案?
function windowWidth() {
var docElemProp = window.document.documentElement.clientWidth,
body = window.document.body;
return window.document.compatMode === "CSS1Compat" && docElemProp || body && body.clientWidth || docElemProp;
}
取自 jQuery 源(并稍加修改):
https://github.com/jquery/jquery/blob/master/src/dimensions.js#L42 https://github.com/jquery/jquery/blob/master/src/dimensions.js#L42
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)