📌  相关文章
📜  如何使用 jQuery 获取屏幕、当前网页和浏览器窗口的大小?

📅  最后修改于: 2021-11-24 05:33:13             🧑  作者: Mango

jQuery 可用于获取当前页面的尺寸。尺寸包括屏幕、视口和文档高度以及宽度。

  • 获取窗口尺寸:窗口尺寸是浏览器窗口的尺寸。这是调整浏览器大小时更改的大小。选择窗口对象后,可以使用 height() 和 width() 方法访问窗口的高度和宽度。
  • 获取文档尺寸:文档大小是 HTML 文档的大小。选择文档对象后,可以使用 height() 和 width() 方法访问文档的高度和宽度。
  • 获取屏幕尺寸:屏幕尺寸是用户屏幕的总尺寸。可以使用 height 和 width 属性访问屏幕的高度和宽度。

例子:



    
        Get the size of the screen, current
        web page and browser window using
        jQuery?
    
      
    

  

    

        GeeksforGeeks     

                    How to get the size of the screen,          current web page and browser         window using jQuery?                 

Window Height is:               

           

Windows Width is:               

           

Document Height is:               

           

Document Width is:               

           

Screen Height is:               

           

Screen Width is:               

                                               

输出:

  • 点击按钮前:
    点击前
  • 点击按钮后:
    点击后