EverCrest Message Forums
You are not logged in. Login or Register.
Author
Topic: Javascript Question
Ghost of Forums Past
Pancake
posted 02-24-2010 08:33:16 AM
I opened a window using window.open. I pass in the argument scrollbars and set the value to either yes or no.

I am now in the child window. My javascript is running. I want to know if the window has scrollbars enabled or not. How do I do this?

- I am in IE so window.scrollbars/this.scrollbars won't return anything
- The window's scrollbars exist outside the body.
- Looking at the document's width will tell me about the document. I can even figure out if there are scrollbars in the document. This will not tell me anything about the window itself.
- The width of the scrollbar in question changes dependent on what the currently selected Windows Desktop Theme is, for ascetic reasons.
- Again, document.documentElement.clientHeight < document.body.offsetHeight or anything else related to the document will tell me about the document, not the window itself.

Ghost of Forums Past fucked around with this message on 02-24-2010 at 08:34 AM.

Katrinity
Cookie Goddess!
posted 02-25-2010 10:08:36 AM
First, is this vertical or horizontial scrollbars you're looking to monitor?

Vertical: Have you tried document.body.scrollHeight > document.body.clientHeight?

Horizontial
Have you tried comparing document.width and window.innerWidth?

Both should compare the viewable space with the actual width of the window itself. If the former is bigger than the latter, you have scrollbars most likely.

Cookie Goddess Supreme
Furry Kitsune of Power!
Pouncer of the 12th degree!
"Cxularath ftombn gonoragh pv'iornw hqxoxon targh!"
Translated: "Sell your soul for a cookie?"
Ghost of Forums Past
Pancake
posted 02-25-2010 10:25:57 AM
Neither document.width or window.innerWidth are supported in Internet Explorer, just like this.scrollbars is not.

Looking at document.body will tell me about the document, including whether or not the document controls strollbars.

Unfortunately, even if document.body's overflow style was set to always show scrollbars, it wouldn't affect the window's scrollbars one way or another. In fact, if you did this, you could have scrollbars attached to the document and scrollbars attached to the window.

I can get the width of the body, if it has scrollbars, and the like. Unfortunately, this is not enough information for me to do what I need to do. I need to figure out if the application window has scrollbars so I can properly call window.sizeTo in Internet Explorer.

Calling window.sizeTo resizes the application window, not just the inner body. That means the file open/etc tabs on the top, the scrollbar on the right, the resize bar on the left, and everything else need to be taken into account. You can't know this by looking at the body. Technically, you can't know it at all because every windows theme has a different padding, but I'm assuming everyone is using the default theme for their given Operating System.

Ghost of Forums Past fucked around with this message on 02-25-2010 at 10:29 AM.

Katrinity
Cookie Goddess!
posted 02-25-2010 03:09:01 PM
Nevermind.

What you're asking might not exist or its a very complicated bit of code to figure it out.

Katrinity fucked around with this message on 02-25-2010 at 03:12 PM.

Cookie Goddess Supreme
Furry Kitsune of Power!
Pouncer of the 12th degree!
"Cxularath ftombn gonoragh pv'iornw hqxoxon targh!"
Translated: "Sell your soul for a cookie?"
Ghost of Forums Past
Pancake
posted 02-25-2010 03:33:32 PM
quote:
ACES! Another post by Katrinity:
Nevermind.

What you're asking might not exist or its a very complicated bit of code to figure it out.


So far I asked on Something Awful, Stack Overflow, here, an e-mail to my co-workers, and on the ASP.Net forums.

It's gotten to the point where I may actually sacrifice an MSDN trouble ticket for a solution or conformation that none exists.

Ghost of Forums Past fucked around with this message on 02-25-2010 at 03:34 PM.

Katrinity
Cookie Goddess!
posted 02-25-2010 03:45:14 PM
Reading up on it, it seems the major issue here is IE. It doesn't support the properties which would make what you want to do alot simpler.
Cookie Goddess Supreme
Furry Kitsune of Power!
Pouncer of the 12th degree!
"Cxularath ftombn gonoragh pv'iornw hqxoxon targh!"
Translated: "Sell your soul for a cookie?"
All times are US/Eastern
Hop To: