473,396 Members | 2,055 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,396 software developers and data experts.

scrollbar

is there a method to get scrollbar position?
Jul 20 '05 #1
6 6884
Cool Mentalist wrote:
is there a method to get scrollbar position?


window.pageXOffset
window.pageYOffset
PointedEars
Jul 20 '05 #2
"Thomas 'PointedEars' Lahn" wrote on 12/11/2003:
Cool Mentalist wrote:
is there a method to get scrollbar position?


window.pageXOffset
window.pageYOffset


Is the IE implementation of those properies broken or missing? I get
'undefined' with both. The same holds true with the x and y
properties of Link and Anchor objects. However, the x and y
properties of the event object have values.

Mike

--
Michael Winter
M.Winter@[no-spam]blueyonder.co.uk (remove [no-spam] to reply)
Jul 20 '05 #3
"Michael Winter" <M.Winter@[no-spam]blueyonder.co.uk> wrote in message
news:g5*********************@news-text.cableinet.net...
"Thomas 'PointedEars' Lahn" wrote on 12/11/2003:
Cool Mentalist wrote:
is there a method to get scrollbar position?


window.pageXOffset
window.pageYOffset


Is the IE implementation of those properies broken or missing?

<snip>

IE does not implement them at all. They are the preferred values to read
but if absent (so in IE) the scrollTop and scrollLeft values can be read
from the root element. Exactly which element is the root element depends
on the browser/version _and_ (if it exists) the "compatMode".

In the absence of pageXOffset/YOffset value I would test to see if
document.compatMode is defined, if it is not then the root element is
document.body. If it is defined and holds the string value "CSS1Compat"
then the root element is document.documentElement (the HTML element) and
the scroll values should be read from there. Any other values of
document.compatMode ("BackCompat", "QuirksMode", etc) mean that
document.body is still the root element and it should be read for the
required values.

Richard.
Jul 20 '05 #4
I used document.body.scrollTop and it worked a treat. I take it i should put in
pageXOffset for other browsers tho.

Nick
Jul 20 '05 #5
Cool Mentalist wrote:
I used document.body.scrollTop and it worked a treat.
I take it i should put in pageXOffset for other browsers tho.


Yes, you should:

if (typeof pageXOffset != "undefined")
{
... pageXOffset ...
}
else if (/* test suggested by Richard */)
{
... referenceToRootElement.scrollTop ...
}
HTH

PointedEars
Jul 20 '05 #6
Cool Mentalist wrote:
I used document.body.scrollTop and it worked a treat.
I take it i should put in pageXOffset for other browsers tho.


Yes, you should:

if (typeof pageYOffset != "undefined")
{
... pageYOffset ...
}
else if (/* test suggested by Richard */)
{
... referenceToRootElement.scrollTop ...
}
The same goes for `pageXOffset' and `scrollLeft'.
HTH

PointedEars
Jul 20 '05 #7

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

Similar topics

7
by: Sujan | last post by:
Hello all, Is it possible to remove scrollbar(s) without using frames. Is there any code which could be applied in body tag to remove scrollbar(s). Thanks in adv, Sujan
4
by: Price Brattin | last post by:
I dragged a datagrid onto a VB.Net WinForm and used the properties page and a few lines of code to set it up, including the DataSource. No wizard setup was used. It works fine except for one...
9
by: kjs | last post by:
Is there any was to control the color of the scrollbars when using the 'overflow: scroll' attribute? TIA, Karl
0
by: h-h | last post by:
BODY { scrollbar-face-color: #f5f5f5; scrollbar-highlight-color: #666666; scrollbar-shadow-color: #666666; scrollbar-3dlight-color: #ffffff; scrollbar-arrow-color: #666666;...
1
by: Shun | last post by:
Hello, How to the add a blue color scrollbar to the browser Left and bottom. Thanx Shun
0
by: d.steininger | last post by:
Hi there! Is there a way to bind a Textbox.Text to a ScrollBar.Value (not the Textbox-own Scrollbar) and vice versa? The Problem: I have to deal with two controls. The Textbox should accept...
14
by: Michael Weis | last post by:
Hello all, as a non-professional in these things, I searched for this topic but found no satisfying answer: I have to create a site with 3 frames. (Please no diskussion about the sense of...
2
by: kurt sune | last post by:
How do I render the scrollbars by CSS in a listbox? I have understood that an asp listbox gets rendered as a select element. So I tried first by adding a style element: ..TA...
3
by: nicky77 | last post by:
Hi, before you say it i know frames are bad practice - but i'm developing dynamic content on a site which has already been designed, so alas there's no option but to use them. Anyway, I just want to...
1
by: Tom | last post by:
First, I posted a similar request for help in another group and now don't find the posting. Problem with my newsreader perhaps ... but apologies if this appears as a cross posting. My code is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.