/[drupal]/contributions/modules/bugbits/bugbits_iframe.js
ViewVC logotype

Contents of /contributions/modules/bugbits/bugbits_iframe.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Fri Aug 21 23:19:21 2009 UTC (3 months, 1 week ago) by daften
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +58 -0 lines
File MIME type: text/javascript
Copied the DRUPAL-6--1 branch to head (merge didn't seem to work)
1 //Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
2 //Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
3 var iframeids=["mantis_frame"]
4
5 //Should script hide iframe from browsers that dont support this script (non IE5+/NS6+ browsers. Recommended):
6 var iframehide="yes"
7
8 var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
9 var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers
10
11 function resizeCaller() {
12 var dyniframe=new Array()
13 for (i=0; i<iframeids.length; i++){
14 if (document.getElementById)
15 resizeIframe(iframeids[i])
16 //reveal iframe for lower end browsers? (see var above):
17 if ((document.all || document.getElementById) && iframehide=="no"){
18 var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
19 tempobj.style.display="block"
20 }
21 }
22 }
23
24 function resizeIframe(frameid){
25 var currentfr=document.getElementById(frameid)
26 if (currentfr && !window.opera){
27 currentfr.style.display="block"
28 if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
29 currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
30 else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
31 currentfr.height = currentfr.Document.body.scrollHeight;
32 if (currentfr.addEventListener)
33 currentfr.addEventListener("load", readjustIframe, false)
34 else if (currentfr.attachEvent){
35 currentfr.detachEvent("onload", readjustIframe) // Bug fix line
36 currentfr.attachEvent("onload", readjustIframe)
37 }
38 }
39 }
40
41 function readjustIframe(loadevt) {
42 var crossevt=(window.event)? event : loadevt
43 var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
44 if (iframeroot)
45 resizeIframe(iframeroot.id);
46 }
47
48 function loadintoIframe(iframeid, url){
49 if (document.getElementById)
50 document.getElementById(iframeid).src=url
51 }
52
53 if (window.addEventListener)
54 window.addEventListener("load", resizeCaller, false)
55 else if (window.attachEvent)
56 window.attachEvent("onload", resizeCaller)
57 else
58 window.onload=resizeCaller

  ViewVC Help
Powered by ViewVC 1.1.2