Скрипт позволяет менять высоту слоя мышью. В Opera и IE нормально, а в Mozilla FireFox 2.0.0.3 при высоте слоя больше высоты окна, слой слишком сильно растягивается, больше чем указывается. Помогите разобраться как сделать чтоб нормально работало или дайте другой скрипт для этого дела.
P.S. Сразу признаюсь: мои только 3 последние функции.
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.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
<html><head>
<script type="text/javascript">
var USER_DATA = {
Browser: {
KHTML: /Konqueror|KHTML/.test(navigator.userAgent) &&
!/Apple/.test(navigator.userAgent),
Safari: /KHTML/.test(navigator.userAgent) &&
/Apple/.test(navigator.userAgent),
Opera: !!window.opera,
MSIE: !!(window.attachEvent && !window.opera),
Gecko: /Gecko/.test(navigator.userAgent) &&
!/Konqueror|KHTML/.test(navigator.userAgent)
},
OS: {
Windows: navigator.platform.indexOf("Win") > - 1 ,
Mac: navigator.platform.indexOf("Mac") > - 1 ,
Linux: navigator.platform.indexOf("Linux") > - 1
}
};
var IS_IE = USER_DATA['Browser'].MSIE;
function NaN0(th) { return isNaN(th) ? 0 : th; };
function getPosition(e){
var left = 0 ;
var top = 0 ;
while (e.offsetParent) {
left += e.offsetLeft + (e.currentStyle ?
parseInt(NaN0(e.currentStyle.borderLeftWidth)) : 0 );
top += e.offsetTop + (e.currentStyle ?
parseInt(NaN0(e.currentStyle.borderTopWidth)) : 0 );
e = e.offsetParent;
}
left += e.offsetLeft + (e.currentStyle ?
parseInt(NaN0(e.currentStyle.borderLeftWidth)) : 0 );
top += e.offsetTop + (e.currentStyle ?
parseInt(NaN0(e.currentStyle.borderTopWidth)): 0 );
return {x:left, y:top};
}
function getAlignedPosition(e) {
var left = 0 ;
var top = 0 ;
while (e.offsetParent) {
left += e.offsetLeft + (e.currentStyle ?
parseInt(NaN0(e.currentStyle.borderLeftWidth)) : 0 );
top += e.offsetTop + (e.currentStyle ?
parseInt(NaN0(e.currentStyle.borderTopWidth)) : 0 );
e = e.offsetParent;
if (e.scrollLeft) {left -= e.scrollLeft; }
if (e.scrollTop) {top -= e.scrollTop; }
}
var docBody = document.documentElement ?
document.documentElement : document.body;
left += e.offsetLeft +
(e.currentStyle ?
parseInt(NaN0(e.currentStyle.borderLeftWidth))
: 0 ) +
(IS_IE ? parseInt(NaN0(docBody.scrollLeft)) : 0 ) -
parseInt(NaN0(docBody.clientLeft));
top += e.offsetTop +
(e.currentStyle ?
parseInt(NaN0(e.currentStyle.borderTopWidth))
: 0 ) +
docBody.scrollTop -
parseInt(NaN0(docBody.clientTop));
return {x:left, y:top};
}
function mouseCoords(ev) {
if (ev.pageX || ev.pageY) {
return {x:ev.pageX, y:ev.pageY};
}
var docBody = document.documentElement
? document.documentElement
: document.body;
return {
x: ev.clientX + docBody.scrollLeft - docBody.clientLeft,
y: ev.clientY + docBody.scrollTop - docBody.clientTop
};
}
function getMouseOffset(target, ev, aligned) {
ev = ev || window.event;
if (aligned == null) aligned = false;
var docPos = aligned
? getAlignedPosition(target)
: getPosition(target);
var mousePos = mouseCoords(ev);
return {
x: mousePos.x - docPos.x,
y: mousePos.y - docPos.y
};
}
function resize_go(event) {
pos=getMouseOffset(users, event, true);
document.getElementById('users').style.height=pos.y;
return true;
};
function resize_stop() {
document.onmousemove="";
document.onmouseup="";
return true;
};
function resize(event) {
document.onmousemove=resize_go;
document.onmouseup=resize_stop;
return true;
};
</script>
</head>
<body>
<table border= 0 width= 100 % cellspacing="0" cellpadding="1" bgcolor=#B3B9C3><tr><td>
<table border= 0 width= 100 % bgcolor=white><tr><td>
<div id="users" style="width: 100%; height: 100; overflow: auto; contentEditable=true">
</div></td></tr><tr bgcolor=#D0D9F6><td align=right onmousedown="resize(event);"> </td></tr></table></td></tr></table>
</body>
</html>