473,287 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

What could cause scrollWidth to return 0?

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.documentElement.scrollWidth + gMargin + 'px';
else
ret = doc.body.scrollWidth + gMargin + 'px';
} // if (doc.all)
else if (doc.width)
// Other browsers.
ret = doc.width + gMargin + 'px';

// alert('(getScrollWidth) 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.documentElement.scrollHeight + gMargin + 'px';
else
ret = doc.body.scrollHeight + gMargin + 'px';
} // if (doc.all)
else if (doc.height)
// Other browsers.
ret = doc.height + gMargin+ 'px';

// alert('(getScrollHeight) 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.documentElement.scrollHeight + gMargin + 'px';
else
ret = doc.body.scrollHeight + gMargin + 'px';
} // if (doc.all)
else if (doc.height)
// Other browsers.
ret = doc.height + gMargin+ 'px';

// alert('(getScrollHeight) 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(document, parent.getScrollWidth(),
parent.getScrollHeight(), '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
Jul 20 '05 #1
1 6154
I accidentally duplicated the getScrollHeight() function call and forgot the
resizeIFrame() function call, here is the latter:

function resizeIFrame(id, x, y, callerId)
{
var SX = "";
var SY = "";

if (true)
{
SX = x + '';
SY = y + '';

if (SX.indexOf('px') == -1)
SX = SX + 'px';

if (SY.indexOf('px') == -1)
SY = SY + 'px';

// alert("(resizeIFrame), called by '" + callerId + "'> id = " + id
+ ", x = " + x + ", y = " + y);

var iframeElement = null;

// alert("(resizeIFrame) set iframeElement to null.");
if (top.document.all)
{
// Internet Explorer.
// alert('(resizeIframe) IE browser.');
iframeElement = top.document.all[id];

} // if (document.all)
else if (top.document.height)
{
// Other browsers.
// alert('(resizeIframe) Non-IE browser.');
iframeElement =
top.document.getElementById(id);
} // else if (top.document.height)

if (iframeElement)
{
iframeElement.style.width = x;
iframeElement.style.height = y;
// alert("(resizeIFrame) iframeElement.style (width, height) = "
+ iframeElement.style.width + ", " + iframeElement.style.height);
}
else
alert('(resizeIFrame) iframeElement is null for id = ' + id);
} // if (true)
}

// ---------------------------------------------------------------
--

Robert Oschler
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bartosz Wegrzyn | last post by:
I use onblue event to validate fields in my form. I do this onblur="return isname()" and so so ... I have one form with 20 fields. My problem is that when the focus is for example on the...
8
by: Eric Osman | last post by:
My javascript program has reason to want to stop. For example, function A has 5 lines, the second of which calls function B, which has 5 lines, the first of which calls function C. But...
11
by: Aing | last post by:
Anyone knows what can be cause of this problem? //////////////////////////////////////////////////////////// typedef struct _date_struct { int date,month,year; }date_struct; Class Date {...
9
by: John Cho | last post by:
// CHO, JOHN #include<iostream> class fracpri{ int whole; int numer; int denom;
3
by: Prabh | last post by:
Hello, I am wondering whats wrong with the following code. It is crashing on Linux, but works fine on AIX. The function basically get DbNm@Srvr string and then return DbNm and Srvr back to...
16
by: Bob Hairgrove | last post by:
Consider the classic clone() function: class A { public: virtual ~A() {} virtual A* clone() const = 0; }; class B : public A { public:
0
by: rodchar | last post by:
hey all, i have the following DIV element in my page: <DIV id="OnlyDIV" style="OVERFLOW: hidden; WIDTH: 300px">... This div element contains a datalist. This works fine for me on a regular...
15
by: robert maas, see http://tinyurl.com/uh3t | last post by:
Here's the source: #include <stdio.h> #include <errno.h> main () { char* str = "9999999999"; long long int llin; char* endptr; /* Set by strtoll */ int nch; errno = 0; llin = strtoll(str,...
5
by: liketofindoutwhy | last post by:
for the code var node = document.getElementById("something") alert(node.offsetWidth) is very similar to node.clientWidth and node.scrollWidth I just wonder why offsetWidth is well...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.