用户屏幕的高度和宽度保存在变量中[关闭]

Can We Copy The height & Width of the screen of the viewer or user in variables like***

var h=?

var w=?

var h=screen.height should do it. Same with width.

Something like that?

w = $(window).width(); //get current window width
h = $(window).height(); //get current window height

jQuery way:

//page load
var windowW = $(window).width();
var windowH = $(window).height();

//window size change
$(window).resize(function() {
    windowW = $(window).width();
    windowH = $(window).height();
});

What exactly do you want?

var h = screen.height,
w = screen.width;