Making sure header.php can't be called by itself
[moodle.git] / mod / hotpot / iframe.js
blobd72eac34faabb24d8a0054384d5ab932c71a64e8
1 function domSniffer() {
2     var t = true;
3     var s = navigator.userAgent;
4     if (s.indexOf("Mac") >=0) this.mac = t;
5     if (s.indexOf("Opera") >=0) this.opera = t;
6     var d = document;
7     if (d.layers) this.n4 = t;
8     if (d.childNodes) this.dom = t;
9     if (d.all && d.plugins) this.ie = t;
11 function getContentH(lyr) {
12     return (is.n4) ? lyr.document.height : (is.ie) ? (is.mac ? lyr.offsetHeight : lyr.scrollHeight) : (is.opera) ? lyr.style.pixelHeight : (is.dom) ? lyr.offsetHeight : 0;
14 function px(i) {
15     return i + "px";
17 function setSize(obj, w, h) {
18     if (is.n4) {
19         if (w) obj.width = w;
20         if (h) obj.height = h;
21     } else if (is.opera) {
22         // opera 5 needs pixelWidth/Height
23         if (w) obj.style.pixelWidth = w;
24         if (h) obj.style.pixelHeight = h;
25     } else {
26         if (w) obj.style.width = px(w);
27         if (h) obj.style.height = px(h);
28     }
30 function getElement(id, lyr) {
31     var d = (document.layers && lyr) ? lyr.document : document;
32     var obj = (document.layers) ? eval("d."+id) : (d.all) ? d.all[id] : (d.getElementById) ? d.getElementById(id) : null;
33     return obj;
35 function set_embed_object_height(evt, embed_object) {
36     if (typeof(embed_object)=='undefined') {
37         if (evt) {
38             // we are being called by the onload event handler
39             if (evt.target) { // most browsers
40                 embed_object = evt.target;
41             } else if (evt.srcElement) { // IE
42                 embed_object = evt.srcElement;
43             }
44         }
45     }
46     var obj = null;
47     if (embed_object) {
48         if (document.frames) { // IE
49             switch (embed_object.tagName) {
50                 case 'IFRAME':
51                     obj = document.frames[embed_object.name].document;
52                     break;
53                 case 'OBJECT':
54                     obj = embed_object; // already an HTML document element
55                     break;
56             }
57         } else { // Firefox, Safari, Opera, Chrome
58             obj = embed_object.document || embed_object.contentDocument || null;
59         }
60     }
61     if (obj) {
62         if (obj.body) {
63             obj = obj.body;
64         }
65         var h = getContentH(obj);
66         if (h) {
67             setSize(embed_object, 0, h + 65);
68         }
69         // at some point the next two lines were important, but now it doesn't seeme to matter ?!
70         // if (document.all) {
71         //     embed_object.allowTransparency = true;
72         //     obj.style.backgroundColor = 'transparent';
73         // }
74     }
76 is = new domSniffer();