1 |
dpavlin |
905 |
/* FIXME rewrite this */ |
2 |
|
|
|
3 |
|
|
top.ifr_doc = function(ifr) { |
4 |
|
|
if (!ifr) return null; |
5 |
|
|
if (ifr.contentDocument) return ifr.contentDocument; |
6 |
|
|
if (ifr.contentWindow) { |
7 |
|
|
try { return ifr.contentWindow.document; } |
8 |
|
|
catch (e) { } |
9 |
|
|
} |
10 |
|
|
if (ifr.document) return ifr.document; |
11 |
|
|
if (ifr.window && ifr.window.document) return ifr.window.document; |
12 |
|
|
return null; |
13 |
|
|
}; |
14 |
|
|
|
15 |
|
|
top.ifr_scroll_to_top = function(ifr) { |
16 |
|
|
if (!ifr) return; |
17 |
|
|
if (ifr.contentWindow && ifr.contentWindow.scrollTo) ifr.contentWindow.scrollTo(0, 0); |
18 |
|
|
else if (ifr.window && ifr.window.scrollTo) ifr.window.scrollTo(0, 0); |
19 |
|
|
else if (ifr.scrollTo) ifr.scrollTo(0, 0); |
20 |
|
|
}; |
21 |
|
|
|
22 |
|
|
top.ifr_get_height = function(ifr) { |
23 |
|
|
if (!ifr) return false; |
24 |
|
|
var doc = top.ifr_doc(ifr) || null; |
25 |
|
|
if (!doc) return false; |
26 |
|
|
var i; |
27 |
|
|
var candidates = [ |
28 |
|
|
doc.body ? doc.body.scrollHeight : null, // IE5 |
29 |
|
|
doc.body ? doc.body.offsetHeight : null, // NS6 |
30 |
|
|
doc.body ? doc.body.clientHeight : null, |
31 |
|
|
doc.body ? doc.body.innerHeight : null, |
32 |
|
|
doc.innerHeight, |
33 |
|
|
doc.offsetHeight, |
34 |
|
|
doc.height |
35 |
|
|
]; |
36 |
|
|
|
37 |
|
|
/* |
38 |
|
|
var tmp = new Array(); |
39 |
|
|
for (i = 0; i < candidates.length; i++) { |
40 |
|
|
if (String(typeof(candidates[i])) == 'undefined') continue; |
41 |
|
|
if (candidates[i] == null) continue; |
42 |
|
|
h = parseInt(candidates[i]); |
43 |
|
|
if (!isNaN(h)) tmp[tmp.length] = String(i) + ': ' + String(h); |
44 |
|
|
} |
45 |
|
|
alert(String(ifr.id || '') + "\n" + tmp.join("\n")); |
46 |
|
|
*/ |
47 |
|
|
|
48 |
|
|
var h = -1; |
49 |
|
|
for (i = 0; h <= 0 && i < candidates.length; i++) { |
50 |
|
|
if (String(typeof(candidates[i])) == 'undefined') continue; |
51 |
|
|
if (candidates[i] == null) continue; |
52 |
|
|
h = parseInt(candidates[i]); |
53 |
|
|
if (isNaN(h)) h = -1; |
54 |
|
|
} |
55 |
|
|
return h; |
56 |
|
|
}; |
57 |
|
|
|
58 |
|
|
top.ifr_resize = function(ifr) { |
59 |
|
|
if (!ifr) return false; |
60 |
|
|
var h = top.ifr_get_height(ifr); |
61 |
|
|
if (h < 0) return; |
62 |
|
|
top.ifr_scroll_to_top(ifr); |
63 |
|
|
ifr.height = h; |
64 |
|
|
ifr.style.height = String(h) + 'px'; |
65 |
|
|
}; |