function hasScrollbar() {return document.body.scrollHeight > (window.innerHeight || document.documentElement.clientHeight);}调用该方法便可以 原理很简单 就是看内容的高度是否比浏览器更高