473,722 Members | 2,211 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Return to Previous Position

Howdy,

I know how to tell a DIV with a vertical scroll bar how far to scroll:

document.getEle mentById( 'myDIV' ).scrollTop += 40;
However, under certain conditions, 'myDIV' is hidden. Upon once again being
visible, I need to return (scroll) to the same position where the user was
before 'myDIV' was hidden. However, I can't figure out how to store the current
position for later retrieval. I've tried using the following:

thePosition = document.getEle mentById( 'myDIV' ).scrollTop;

But, scrollTop always seems to want to store this value instead:

thePosition = document.body.s crollTop;

Since the main window doesn't have a scroll bar on my screen, scrollTop always
has a value of 0. How do I find the scrolled position of the 'myDIV' instead of
the scrolled position of the body? Since I can set that value, I'm wondering
why I can't retrieve it.

Thanks!
Jim
Jul 23 '05 #1
4 1467
BrassWorld wrote on 25 apr 2004 in comp.lang.javas cript:
Since the main window doesn't have a scroll bar on my screen,
scrollTop always has a value of 0. How do I find the scrolled position
of the 'myDIV' instead of the scrolled position of the body? Since I
can set that value, I'm wondering why I can't retrieve it.


<http://www.webreferenc e.com/js/tips/991203.html>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #2
<< <http://www.webreferenc e.com/js/tips/991203.html> >><BR><BR>
Unfortunately, that page only has information capturing a "window's"
scrollbars. Remember, my browser's window won't have (or need) any scrollbars.
I need information about determining a DIV's scrollbar. The fixed size of this
DIV is smaller than most screen sizes. However, the content inside of that DIV
is scrollable. Once again, my browser window itself will not scroll.

I've already spent a good deal of time on Google trying to find an answer to
this. Since I haven't be able to find an answer to my problem, maybe a good
solution doesn't exist.

Thanks, anyway.
Jim
Jul 23 '05 #3
BrassWorld wrote on 25 apr 2004 in comp.lang.javas cript:
<< <http://www.webreferenc e.com/js/tips/991203.html> >><BR><BR>
Unfortunately, that page only has information capturing a "window's"
scrollbars.


You miss the point:

x = document.body.s crollTop

can be changed to

x = document.getEle mentById("myDiv Id").scrollTo p

To the NS version I cannot help you.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #4
<< You miss the point:

x = document.body.s crollTop

can be changed to

x = document.getEle mentById("myDiv Id").scrollTo p

To the NS version I cannot help you. >><BR><BR>
That is exactly how I had it written on my first post. [Actually, thePosition =
document.getEle mentById( 'myDIV' ).scrollTop;] Thanks for confirming that the
initial way I was doing this actually was the correct way. I needed to be
reminded that different browsers do not always respond to a given situation in
the same way.

I was testing my code in Safari on the Mac. It does function (but not real
accurately) with Mozilla on the Mac, but not in Safari. It does, however,
function properly in IE on the Mac. I test with Windows browsers shortly.

Jim
Jul 23 '05 #5

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

Similar topics

3
1738
by: Mike Partridge | last post by:
Is it possible to access your caller's (not parent) context while inside a <xsl:template match...> or <xsl:for-each...>? Here is the xml I'm using: <report-set> ...<report> .....<detail-data> .......<detail-column position="1" dsc="col1" sum_fg="0"/> .......<detail-column position="2" dsc="col2" sum_fg="1"/> .......<detail-column position="3" dsc="col3" sum_fg="1"/>
1
4341
by: Brian Basquille | last post by:
Hi all, Can anyone give me an idea of how to keep track of last mouse position and previous mouse position before it in a MouseMove() method? Would i need to load them both into an array...? Brian
68
4625
by: Jim Langston | last post by:
I remember there was a thread a while back that was talking about using the return value of a function as a reference where I had thought the reference would become invalidated because it was a temporary but it was stated that it would not. This has come up in an irc channel but I can not find the original thread, nor can I get any code to work. Foo& Bar( int Val ) { return Foo( Val ); }
2
13458
by: Hvid Hat | last post by:
class Sprite { private Vector2 position; public Vector2 Position { get { return position; } set { position = value; } } ... }
0
8738
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9381
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9086
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8042
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5994
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4501
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3207
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 we have to send another system
2
2600
muto222
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.