I am wondering a little when I look at this code:
// Get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();
...
// Get the window height and width
var winH = $(window).height();
var winW = $(window).width();
What is the difference between $(document).height();
and $(window).height();
?
The screen object refers to the actual monitor window or desktop size. Note that if you have a multi-mon setup then you will have multiple screen objects. A window object belongs to a single screen , though not very window belongs to the same screen .
Use window. innerWidth and window. innerHeight to get the current screen size of a page.
$(window). width() gets the entire width of the window, including things like the scroll bar .
Window is the top level client side object, which contains the document. This jsFiddle shows that both $(window).height()
and $(document).height()
return the same value: http://jsfiddle.net/jackrugile/5xSuv/
Window is the size of the viewport and does not include any of the chrome or browser interface, if I am not mistaken. I believe that the values of both will always be the same, unless you are referencing something like an iframe within a window.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With