/[webpac]/trunk2/out/js/iframe.js
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk2/out/js/iframe.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 585 - (show annotations)
Sat Nov 6 18:37:30 2004 UTC (19 years, 5 months ago) by dpavlin
File MIME type: application/javascript
File size: 2189 byte(s)
reduce hack to just 5px (we actually like extra spacing to next item :-)

1 // load iframe and resize it
2 // written by Dobrica Pavlinusic <dpavlin@rot13.org>
3 // based on great hints from Robert Avilov
4
5 var iframe_id_cache = Array();
6
7 function iframe_id(name) {
8 if (! iframe_id_cache[name]) {
9 iframe_id_cache[name] = self.document.getElementById(name);
10 }
11 return iframe_id_cache[name];
12 }
13
14
15 function iframe_doc(name) {
16 if (iframe_id(name).contentDocument) return iframe_id(name).contentDocument;
17 if (iframe_id(name).contentWindow) {
18 try {
19 return iframe_id(name).contentWindow.document;
20 } catch (e) {};
21 }
22 if (iframe_id(name).document) return iframe_id(name).document;
23 return null;
24 }
25
26 function iframe_height(name) {
27
28 var doc = iframe_doc(name);
29
30 if (doc.body) {
31 var h = -1;
32 var h1 = -1;
33
34 if (doc.body.scrollHeight) {
35 h1 = parseInt(doc.body.scrollHeight) || -1;
36 //alert(name+" scrollHeight "+h1);
37 if (h1 > h) h = h1;
38 }
39 if (doc.body.clientHeight) {
40 h1 = parseInt(doc.body.clientHeight) || -1;
41 //alert(name+" clientHeight "+h1);
42 if (h1 > h) h = h1;
43 }
44
45 /*
46 var elm = document.getElementById(name);
47 if (elm) {
48 elm.style.height = 'auto';
49 h1 = elm.offsetHeight;
50 alert(name+" offsetHeight "+h1);
51 if (h1 > h) h = h1;
52 }
53 */
54
55 return h + 5;
56
57 }
58 return 50;
59 }
60
61 function iframe_resize(name) {
62
63 var el=iframe_id(name);
64
65 if (! el || ! el.src) return;
66
67 el.style.height = String(iframe_height(name)+'px');
68
69 // hide wait message
70 var w_el = iframe_id(name.replace(/^i/,"w"));
71 if (w_el) w_el.style.display = 'none';
72 }
73
74 function iframe_load(name,url) {
75
76 if (! name || ! url) return false;
77
78 var el=iframe_id(name);
79
80 // is there src, and is src same?
81 if (el.src) {
82 var old_src = el.src;
83 // remove query
84 var q = el.src.indexOf("?");
85 if (q > 0) old_src = old_src.substr(0,q);
86 // now compare just last parts
87 old_src = old_src.substr(old_src.length - url.length);
88 //alert(old_src+" == "+url+" q="+q);
89 if (old_src == url) return false;
90 }
91
92 // if iframe name if i_something, show waiting message called w_something
93 var w_el = iframe_id(name.replace(/^i/,"w"));
94 if (w_el) w_el.style.display = '';
95
96 if (location.search) url += location.search;
97
98 el.style.height = '0px';
99 el.src = url;
100
101 return false;
102 }
103

  ViewVC Help
Powered by ViewVC 1.1.26