火狐怎么通过js获取屏幕的宽度

JavaScript05

火狐怎么通过js获取屏幕的宽度,第1张

获取屏幕宽度为:window.screen.width

获取视口宽度(页面宽度):document.documentElement.clientWidth

                window.addEventListener('resize', function() {

                    console.info( document.documentElement.clientWidth)

                    console.info( window.screen.width )

                })

//js部分

$(document).ready(function() {

$("#button").click(function() {

alert("高:"+$(document).height()+" 宽:"+$(document).width())

})

}) <!-- html 部分 -->

<button id="button">点击显示</button>

你真确定不好使?检查一下jquery路径吧。