I have a "child" document that I use for an IFRAME element that I put into
several "parent" documents. These "parent" documents therefore contain the
IFRAME whose SRC property is set to the "child" document.
The parent(s) have three Javascript functions, here they are:
// =============== ==============
var gMargin = 5;
function getScrollWidth( doc, callerId)
{
if (true)
{
// If no document reference was passed, assume it is the
// current document.
if (!doc)
doc = document;
var ret;
if (doc.all)
{
// Internet Explorer.
if (doc.compatMode &&
doc.compatMode != 'BackCompat')
ret = doc.documentEle ment.scrollWidt h + gMargin + 'px';
else
ret = doc.body.scroll Width + gMargin + 'px';
} // if (doc.all)
else if (doc.width)
// Other browsers.
ret = doc.width + gMargin + 'px';
// alert('(getScro llWidth) Returning scroll width(' + ret + ') to
caller Id: ' + callerId);
return ret;
} // if (true)
}
// =============== ==============
function getScrollHeight (doc, callerId)
{
if (true)
{
// If no document reference was passed, assume it is the
// current document.
if (!doc)
doc = document;
var ret;
if (doc.all)
{
// Internet Explorer.
if (doc.compatMode &&
doc.compatMode != 'BackCompat')
ret = doc.documentEle ment.scrollHeig ht + gMargin + 'px';
else
ret = doc.body.scroll Height + gMargin + 'px';
} // if (doc.all)
else if (doc.height)
// Other browsers.
ret = doc.height + gMargin+ 'px';
// alert('(getScro llHeight) Returning scroll height(' + ret + ') to
caller Id: ' + callerId);
return ret;
} // if (true)
}
// ---------------------------------------------------------------
function getScrollHeight (doc, callerId)
{
if (true)
{
// If no document reference was passed, assume it is the
// current document.
if (!doc)
doc = document;
var ret;
if (doc.all)
{
// Internet Explorer.
if (doc.compatMode &&
doc.compatMode != 'BackCompat')
ret = doc.documentEle ment.scrollHeig ht + gMargin + 'px';
else
ret = doc.body.scroll Height + gMargin + 'px';
} // if (doc.all)
else if (doc.height)
// Other browsers.
ret = doc.height + gMargin+ 'px';
// alert('(getScro llHeight) Returning scroll height(' + ret + ') to
caller Id: ' + callerId);
return ret;
} // if (true)
}
// ---------------------------------------------------------------
In the "onload" event of the "child" document, a call is made to a function
call in the "parent"'s Javascript like this:
<BODY onload="parent. resizeIFrame(do cument, parent.getScrol lWidth(),
parent.getScrol lHeight(), 'test');" >
.... // rest of HTML
</BODY>
causing the "parent" document to resize the IFRAME to the scrollWidth and
scrollHeight of the "child" document. It works great on one "parent"
document, but on another I get 0 for the "child" document's scrollWidth and
scrollHeight properties.
What could cause this?
BTW, Testing is being done with Internet Explorer 6.x.
thx
--
Robert Oschler
several "parent" documents. These "parent" documents therefore contain the
IFRAME whose SRC property is set to the "child" document.
The parent(s) have three Javascript functions, here they are:
// =============== ==============
var gMargin = 5;
function getScrollWidth( doc, callerId)
{
if (true)
{
// If no document reference was passed, assume it is the
// current document.
if (!doc)
doc = document;
var ret;
if (doc.all)
{
// Internet Explorer.
if (doc.compatMode &&
doc.compatMode != 'BackCompat')
ret = doc.documentEle ment.scrollWidt h + gMargin + 'px';
else
ret = doc.body.scroll Width + gMargin + 'px';
} // if (doc.all)
else if (doc.width)
// Other browsers.
ret = doc.width + gMargin + 'px';
// alert('(getScro llWidth) Returning scroll width(' + ret + ') to
caller Id: ' + callerId);
return ret;
} // if (true)
}
// =============== ==============
function getScrollHeight (doc, callerId)
{
if (true)
{
// If no document reference was passed, assume it is the
// current document.
if (!doc)
doc = document;
var ret;
if (doc.all)
{
// Internet Explorer.
if (doc.compatMode &&
doc.compatMode != 'BackCompat')
ret = doc.documentEle ment.scrollHeig ht + gMargin + 'px';
else
ret = doc.body.scroll Height + gMargin + 'px';
} // if (doc.all)
else if (doc.height)
// Other browsers.
ret = doc.height + gMargin+ 'px';
// alert('(getScro llHeight) Returning scroll height(' + ret + ') to
caller Id: ' + callerId);
return ret;
} // if (true)
}
// ---------------------------------------------------------------
function getScrollHeight (doc, callerId)
{
if (true)
{
// If no document reference was passed, assume it is the
// current document.
if (!doc)
doc = document;
var ret;
if (doc.all)
{
// Internet Explorer.
if (doc.compatMode &&
doc.compatMode != 'BackCompat')
ret = doc.documentEle ment.scrollHeig ht + gMargin + 'px';
else
ret = doc.body.scroll Height + gMargin + 'px';
} // if (doc.all)
else if (doc.height)
// Other browsers.
ret = doc.height + gMargin+ 'px';
// alert('(getScro llHeight) Returning scroll height(' + ret + ') to
caller Id: ' + callerId);
return ret;
} // if (true)
}
// ---------------------------------------------------------------
In the "onload" event of the "child" document, a call is made to a function
call in the "parent"'s Javascript like this:
<BODY onload="parent. resizeIFrame(do cument, parent.getScrol lWidth(),
parent.getScrol lHeight(), 'test');" >
.... // rest of HTML
</BODY>
causing the "parent" document to resize the IFRAME to the scrollWidth and
scrollHeight of the "child" document. It works great on one "parent"
document, but on another I get 0 for the "child" document's scrollWidth and
scrollHeight properties.
What could cause this?
BTW, Testing is being done with Internet Explorer 6.x.
thx
--
Robert Oschler
Comment