使用jQuery获取视口的大小 [英] Using jQuery To Get Size of Viewport

查看:282
本文介绍了使用jQuery获取视口的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用jQuery确定浏览器视口的大小,并在调整页面大小后重新检测到它?我需要在该空间中添加一个IFRAME大小(每个边距都稍许出现).

How do I use jQuery to determine the size of the browser viewport, and to redetect this if the page is resized? I need to make an IFRAME size into this space (coming in a little on each margin).

对于那些不知道的人,浏览器视口不是文档/页面的大小.这是滚动前窗口的可见大小.

For those who don't know, the browser viewport is not the size of the document/page. It is the visible size of your window before the scroll.

推荐答案

获取视口的宽度和高度:

To get the width and height of the viewport:

var viewportWidth = $(window).width();
var viewportHeight = $(window).height();

页面大小调整事件:

$(window).resize(function() {

});

这篇关于使用jQuery获取视口的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆