2 //\ overLIB Crossframe Support Plugin
3 //\ This file requires overLIB 4.00 or later.
5 //\ overLIB 4.00 - You may not remove or change this notice.
6 //\ Copyright Erik Bosrup 1998-2004. All rights reserved.
7 //\ Contributors are listed on the homepage.
8 //\ See http://www.bosrup.com/web/overlib/ for details.
15 // Ignore these lines, configuration is below.
17 if (typeof olInfo == 'undefined' || olInfo.simpleversion < 400) alert('overLIB 4.00 or later is required for the Cross Frame Support Plugin.');
18 registerCommands('frame');
25 // Parses FRAME command
26 function parseFrameExtras(pf,i,ar) {
30 if (ar[k] == FRAME) { v = ar[++k]; if(pf == 'ol_'&&compatibleframe(v)) ol_frame = v; else opt_FRAME(v); return k; }
40 // Defines which frame we should point to.
41 function opt_FRAME(frm) {
42 o3_frame = compatibleFrame(frm) ? frm : ol_frame;
45 over = o3_frame.document.layers['overDiv'];
46 } else if (document.all) {
47 over = o3_frame.document.all['overDiv'];
48 } else if (document.getElementById) {
49 over = o3_frame.document.getElementById("overDiv");
55 // Makes sure target frame has overLIB
56 function compatibleFrame(frameid) {
57 if (olNs4 && typeof frameid.document.overDiv == 'undefined') {
59 } else if (document.all && typeof frameid.document.all["overDiv"] == 'undefined') {
61 } else if (document.getElementById && frameid.document.getElementById('overDiv') == null) {
68 // Get frame depth of nested frames
69 function frmDepth(thisFrame,ofrm) {
72 for (var i = 0; i<thisFrame.length; i++) {
73 if (thisFrame[i].length > 0) {
74 retVal = frmDepth(thisFrame[i],ofrm);
75 if (retVal == '') continue;
76 } else if (thisFrame[i] != ofrm) continue;
77 retVal = '[' + i + ']' + retVal;
84 // Gets frame reference value relative to top frame
85 function getFrmRef(srcFrm,tgetFrm) {
88 if (tgetFrm != srcFrm) {
89 var tFrm = frmDepth(top.frames,tgetFrm)
90 var sFrm = frmDepth(top.frames,srcFrm)
91 if (sFrm.length == tFrm.length) {
92 l = tFrm.lastIndexOf('[')
95 while ( sFrm.substring(0,l) != tFrm.substring(0,l) )
96 l = tFrm.lastIndexOf('[',l-1)
102 var cnt = 0, p = '',str = tFrm
103 while ((k = str.lastIndexOf('[')) != -1) {
105 str = str.substring(0,k)
108 for (var i = 0; i<cnt; i++) p = p + 'parent.'
109 rtnVal = p + 'frames' + sFrm + '.'
115 function chkForFrmRef() {
116 if(o3_frame != ol_frame) fnRef = getFrmRef(ol_frame,o3_frame)
121 // PLUGIN REGISTRATIONS
123 registerCmdLineFunction(parseFrameExtras);
124 registerPostParseFunction(chkForFrmRef);