Help needed with scrolling div

J

jonyman

I have a DIV that encapsulates a table with the overflow-y property set
to 'scroll'

What I need is the scroll bar to start at the bottom so that the lowest
contents of the table are visible to the user first.

Any help would be appreciated!!!
 
R

RobG

jonyman said:
I have a DIV that encapsulates a table with the overflow-y property set
to 'scroll'

What I need is the scroll bar to start at the bottom so that the lowest
contents of the table are visible to the user first.

Any help would be appreciated!!!

1. No JavaScript requried: include an invisible anchor at the bottom of
the div content and modify the page URL:

<div style="overflow-y: scroll; ...">
...
<a name="bottomAnchor"></a>
</div>

And add #bottomAnchor to the page URL.


2. Unreliable script version: set the non-standard scrollTop property
to some value greater than the height of the content is ever likely to
be, but it may not work in IE or Mozilla in strict mode.

<div id="scrollMe" style="overflow-y: scroll; ...">
...
</div>
<script type="text/javascript">
document.getElementById('scrollMe').scrollTop = '10000';
</script>
 
J

jonyman

Hi Rob thanks for your reply, I was trying the .scrollTop for a while,
but as i'm using IE7 I dont think that works.

I tried your first suggestion. When appending the anchor name to the
URL it takes me to the scrollable table, but doesn't scroll the actual
table to the location of the anchor.

I found from msdn that if you give the give the anchor an id and use
the scrollintoview method that it pulls the anchor into view.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top