Created
September 17, 2010 19:50
-
-
Save Ozerich/584818 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Geometry.js: функции определения геометрии окна и документа | |
| * | |
| * getWindowX() / getWindowY() : возвращают положение окна на экране | |
| * getViewportWidth() / getViewportHeight() : возвращают размер клиентской области окна | |
| * getHorizontalScroll() / getVerticalScroll() : возвращают смещение по горизонтали/вертикали [!IE] | |
| * getDocumentWidth() / getDocumentHeight() : возвращают размер документа | |
| * getWindowWidth() / getWindowHeight : возвращают размер окна браузера [!IE] | |
| */ | |
| var Geometry = {}; | |
| if(window.screenLeft != undefined) | |
| { | |
| Geometry.getWindowX = function(){ | |
| return window.screenLeft; | |
| } | |
| Geometry.getWindowY = function(){ | |
| return window.screenTop; | |
| } | |
| } | |
| else if(window.screenX != undefined) | |
| { | |
| Geometry.getWindowX = function(){ | |
| return window.screenX; | |
| } | |
| Geometry.getWindowY = function(){ | |
| return window.screenY; | |
| } | |
| } | |
| if(document.documentElement && document.documentElement.clientWidth != undefined) | |
| { | |
| Geometry.getViewportWidth = function(){ | |
| return document.documentElement.clientWidth; | |
| } | |
| Geometry.getViewportHeight = function(){ | |
| return document.documentElement.clientHeight; | |
| } | |
| Geometry.getVerticalScroll = function(){ | |
| return document.documentElement.scrollTop; | |
| } | |
| Geometry.getHorizontalScroll = function(){ | |
| return document.documentElement.scrollLeft; | |
| } | |
| } | |
| else if(document.body.clientWidth != undefined) | |
| { | |
| Geometry.getViewportHeight = function(){ | |
| return document.body.clientHeight; | |
| } | |
| Geometry.getViewportWidth = function(){ | |
| return document.body.clientWidth; | |
| } | |
| Geometry.getHorizontalScroll = function(){ | |
| return document.body.scrollLeft; | |
| } | |
| Geometry.getVerticalScroll = function(){ | |
| return document.body.scrollTop; | |
| } | |
| } | |
| Geometry.getDocumentHeight = function(){ | |
| return document.documentElement.scrollHeight; | |
| } | |
| Geometry.getDocumentWidth = function(){ | |
| return document.documentElement.scrollWidth; | |
| } | |
| Geometry.getWindowHeight = function(){ | |
| return window.outerHeight; | |
| } | |
| Geometry.getWindowWidth = function(){ | |
| return window.outerWidth; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment