common.js
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* This should become a kind of abstraction for browser specific
* stuff.
*/
function browserGlobals ()
{
if(navigator.appName=='Netscape' &&
navigator.appVersion.charAt(0)=='4')
{
this.browser = 'NS';
this.innerWidth = function () { return window.innerWidth; }
this.innerHeight = function () { return window.innerHeight; }
}
else
if(navigator.appName=='Microsoft Internet Explorer' &&
navigator.appVersion.charAt(0)>='4')
{
this.browser = 'IE';
this.innerWidth = function () { return document.body.offsetWidth; }
this.innerHeight = function () { return document.body.offsetHeight; }
}
else
{
this.browser = 'DOM';
this.innerWidth = function () { return window.innerWidth; }
this.innerHeight = function () { return window.innerHeight; }
}
}
var bGlobals = new browserGlobals ();
function objectPos (id, posX, posY)
{
var ob = document.getElementById (id);
var offsetX = (posX < 0) ? bGlobals.innerWidth () : 0;
var offsetY = (posY < 0) ? bGlobals.innerHeight () : 0;
if (posX != 0)
ob.style.left = offsetX + posX;
if (posY != 0)
ob.style.top = offsetY + posY;
}