5
Tôi đã tìm thấy điều này:Chức năng jQuery để có được chế độ xem hiện tại?
getViewport = function() {
var m = document.compatMode == 'CSS1Compat';
return {
l : window.pageXOffset || (m ? document.documentElement.scrollLeft : document.body.scrollLeft),
t : window.pageYOffset || (m ? document.documentElement.scrollTop : document.body.scrollTop),
w : window.innerWidth || (m ? document.documentElement.clientWidth : document.body.clientWidth),
h : window.innerHeight || (m ? document.documentElement.clientHeight : document.body.clientHeight)
};
};
Nhưng jQuery có tích hợp sẵn chức năng này không?
Không có API nào bị cắt, nhưng bạn có thể viết lại những gì bạn có trong jQuery .. Nhưng nếu bạn đang làm việc tốt thì tại sao lại tìm kiếm Giải pháp dựa trên jQuery. Tôi chắc chắn điều này sẽ nhanh hơn rất nhiều so với những gì jQuery sẽ cung cấp cho bạn. –