PageSourceSearch

https://pc.foamworks.co.kr/share/js/fn/Geometry.js

js foamworks.co.kr collected 2026-10-06 14:03:20 UTC 3,070 bytes, 55 lines download raw bytes

1/**
2 * Geometry.js: portable functions for querying window and document geometry
3 *
4 * This module defines functions for querying window and document geometry.
5 *
6 * getWindowX/Y(): return the position of the window on the screen
7 * getViewportWidth/Height(): return the size of the browser viewport area
8 * getDocumentWidth/Height(): return the size of the document.
9 * getHorizontalScroll(): return the position of the horizontal scrollbar
10 * getVerticalScroll(): return the position of the vertical scrollbar
11 *
12 * Note that there is no portable way to query the overall size of the
13 * browser window, so there are no getWindowWidth/Height() functions.
14 *
15 * IMPORTANT: This module must be included in the <body> of a document
16 *            instead of the <head> of the document.
17 */
18var Geometry = {};
19
20if (window.screenLeft) { // IE and others
21  Geometry.getWindowX = function() { return window.screenLeft; };
22  Geometry.getWindowY = function() { return window.screenTop; };
23} else if (window.screenX) { // Firefox and others
24  Geometry.getWindowX = function() { return window.screenX; };
25  Geometry.getWindowY = function() { return window.screenY; };
26}
27
28if (window.innerWidth) { // All browsers but IE
29  Geometry.getViewportWidth = function() { return window.innerWidth; };
30  Geometry.getViewportHeight = function() { return window.innerHeight; };
31  Geometry.getHorizontalScroll = function() { return window.pageXOffset; };
32  Geometry.getVerticalScroll = function() { return window.pageYOffset; };
33} else if (document.documentElement && document.documentElement.clientWidth) {
34  // These functions are for IE6 when there is a DOCTYPE
35  Geometry.getViewportWidth = function() { return document.documentElement.clientWidth; };
36  Geometry.getViewportHeight = function() { return document.documentElement.clientHeight; };
37  Geometry.getHorizontalScroll = function() { return document.documentElement.scrollLeft; };
38  Geometry.getVerticalScroll = function() { return document.documentElement.scrollTop; };
39} else if (document.body.clientWidth) {
40  // These are for IE4, IE5, and IE6 without a DOCTYPE
41  Geometry.getViewportWidth = function() { return document.body.clientWidth; };
42  Geometry.getViewportHeight = function() { return document.body.clientHeight; };
43  Geometry.getHorizontalScroll = function() { return document.body.scrollLeft; };
44  Geometry.getVerticalScroll = function() { return document.body.scrollTop; };
45}
46
47// These functions return the size of the document.  They are not window
48// related, but they are useful to have here anyway.
49if (document.documentElement && document.documentElement.scrollWidth) {
50  Geometry.getDocumentWidth = function() { return document.documentElement.scrollWidth; };
51  Geometry.getDocumentHeight = function() { return document.documentElement.scrollHeight; };
52} else if (document.body.scrollWidth) {
53  Geometry.getDocumentWidth = function() { return document.body.scrollWidth; };
54  Geometry.getDocumentHeight = function() { return document.body.scrollHeight; };
55}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.