I'm looking for a plugin-free way to get the x-coordinate of the visible viewport's right edge, and likewise, the y-coordinate of its bottom edge, using either jQuery or "plain" JavaScript.
Thanks!
var width = document.documentElement.clientWidth || window.innerWidth;
var height= document.documentElement.clientHeight|| window.innerHeight;
I finally settled for this (jQuery-based) solution:
var $w = $(window);
var right_edge_x = $w.scrollLeft() + $w.width();
var bottom_edge_y = $w.scrollTop() + $w.height();
I'm not sure exactly how it differs from the other solutions proposed, let alone whether it's better, but at least I can make some sense of it...
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