Javascript scrollbars question

  • Thread starter Thread starter Shawn B.
  • Start date Start date
S

Shawn B.

Greetings,

I have an IFrame with overflow: auto set. I would like to, using
Javascript, discover whether scrollbars are rendered. In otherwords, I'd
like to know whether there is an overflow or not so I can make a decision
based on that test. I'm at a loss as to figuring this one out. Usually I
can figure anything out in Javascript but this eludes me.

I've tried

if (window.myIFrame.style.overflowY > 0) but overflowY is always empty.

I've tried

window.myIFrame.document.body.style.overflowY but for some reason it is
returning the height of the document containing the IFrame. In otherwords,
the main page is 795 pixels height, but the IFrame is 345 height. With I
use this property, it returns 688 instead of the difference of (375 and 345
which is 30 pixels).

The reason I care is because if there is a scrollbar for the overflow, I
will not render a border on the right but if there is no scrollbar I will
render a border on the right of the IFrame (the div containing the IFrame).


Thanks,
Shawn
 
Compare the element's scrollHeight property to its clientHeight.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
 
Compare the element's scrollHeight property to its clientHeight.

I thought that might work later on after I posted the original message, but
for some strange reason, the scrollHeight property is empty and clientHeight
says 345 (which is correct) but their are still 30px of scrolling space.

In any case, it appears this doesn't work with IFrame, at least not our
IFrame, but it works just fine on Divs and such. I'll figure something out.
This code has been in production and making lots of money since 4 years ago
and it won't be very easy to change (it is a bonafied web application).

But, I did find a temporary work-around that isn't as eloquant, but it did
pass the looko-and-feel test and is going on into QA for production when the
next release ships.

Thanks for the help.
Shawn
 
Back
Top