/[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

Annotation of /trunk2/out/js/iframe.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 580 - (hide annotations)
Mon Nov 1 22:52:44 2004 UTC (19 years, 5 months ago) by dpavlin
File MIME type: application/javascript
File size: 2190 byte(s)
added wait messages, support for url arguments

1 dpavlin 575 // 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 dpavlin 578 var h1 = -1;
33 dpavlin 575
34     if (doc.body.scrollHeight) {
35 dpavlin 578 h1 = parseInt(doc.body.scrollHeight) || -1;
36     //alert(name+" scrollHeight "+h1);
37     if (h1 > h) h = h1;
38 dpavlin 575 }
39 dpavlin 578 if (doc.body.clientHeight) {
40     h1 = parseInt(doc.body.clientHeight) || -1;
41     //alert(name+" clientHeight "+h1);
42     if (h1 > h) h = h1;
43 dpavlin 575 }
44    
45 dpavlin 578 /*
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 dpavlin 575
55 dpavlin 578 return h + 20;
56    
57 dpavlin 575 }
58     return 50;
59     }
60    
61     function iframe_resize(name) {
62    
63 dpavlin 578 var el=iframe_id(name);
64    
65     if (! el || ! el.src) return;
66    
67     el.style.height = String(iframe_height(name)+'px');
68 dpavlin 580
69     // hide wait message
70     var w_el = iframe_id(name.replace(/^i/,"w"));
71     if (w_el) w_el.style.display = 'none';
72 dpavlin 575 }
73    
74     function iframe_load(name,url) {
75    
76     if (! name || ! url) return false;
77    
78 dpavlin 578 var el=iframe_id(name);
79 dpavlin 575
80 dpavlin 578 // is there src, and is src same?
81 dpavlin 580 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 dpavlin 578
92 dpavlin 580 // 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 dpavlin 578 el.style.height = '0px';
99     el.src = url;
100    
101 dpavlin 575 return false;
102     }
103    

  ViewVC Help
Powered by ViewVC 1.1.26