473,486 Members | 1,889 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

scrollbar

is there a method to get scrollbar position?
Jul 20 '05 #1
6 6885
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
26008
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
4389
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
4307
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
1014
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
1467
by: Shun | last post by:
Hello, How to the add a blue color scrollbar to the browser Left and bottom. Thanx Shun
0
2592
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
3932
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
10636
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
3179
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
13705
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
7094
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
6964
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
7173
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6839
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...
1
4863
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.