Hi
I have a DIV overflow:auto scrolling box that products results of user comments from a database.
Problem is, this list is now getting very long in places, so I need to put the scroller in (simple), but here's the problem and the reason I am here........
It needs to start the scroller at the bottom!
We don't want people to have to scroll down. Yes I can put it in reverse order so they see the latest at the top, but the design for over a year now has been such that the last comment is at the bottom and then they can add theirs.
Is it technically possible to begin the scroll from the bottom of the scroll box? I haven't the first clue how to even think of how to do this. Or frankly, what to look for on Google as an answer.
Div Scroll box for results - can it start at the bottom?
Moderator: General Moderators
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Div Scroll box for results - can it start at the bottom?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Div Scroll box for results - can it start at the bottom?
You can do it using named anchors. Put a named anchor where you want the scroll to start and link to the page with a hash leading to that anchor.
Something like:
And the link should end with #start
Something like:
Code: Select all
<a name="start"></a>-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Div Scroll box for results - can it start at the bottom?
Yes I had thought of that, but that means the page will have to link straight to it and when they reach the product page, it will shoot straight to the bottom of the page.
Plus, no one uses a button to go to the user comments now.
Plus, no one uses a button to go to the user comments now.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Div Scroll box for results - can it start at the bottom?
[text]
<a name="bottom"></a>
<script type="text/javascript">
onload = function()
{
location.href = "#bottom";
}
</script>
[/text]
I have also tried this. And yes, it works. It takes the scroller to the bottom but ALSO takes the user straight to the bottom of the page.
The page must load normally and remain at the top - but the scroller near the bottom of a fairly long page must have already scrolled straight to the bottom.
<a name="bottom"></a>
<script type="text/javascript">
onload = function()
{
location.href = "#bottom";
}
</script>
[/text]
I have also tried this. And yes, it works. It takes the scroller to the bottom but ALSO takes the user straight to the bottom of the page.
The page must load normally and remain at the top - but the scroller near the bottom of a fairly long page must have already scrolled straight to the bottom.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Div Scroll box for results - can it start at the bottom?
Using javascript, you can change the scroll position of an element. Something like -
Code: Select all
var comments = document.getElementById('comments');
comments.scrollTop = comments.scrollHeight;-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Div Scroll box for results - can it start at the bottom?
Hi
You may be a "master" according to your username details, but I have no clue with Javascript or how to insert it and "make it happen".
If you could show me how to interpret that into a standard DIV, I'd be grateful.
You may be a "master" according to your username details, but I have no clue with Javascript or how to insert it and "make it happen".
If you could show me how to interpret that into a standard DIV, I'd be grateful.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Div Scroll box for results - can it start at the bottom?
You just used Javascript in your previous post.. if you're not familiar with Javascript, I recommend the MDC guide - https://developer.mozilla.org/en/JavaScript/Guide
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Div Scroll box for results - can it start at the bottom?
That Javascript was from something I found - I did not write it. I am not a JS creator.
I really don't know anything about JS. But this result is needed as a priority, hence asking how to interpret that into JS and make it 'run'.
I really don't know anything about JS. But this result is needed as a priority, hence asking how to interpret that into JS and make it 'run'.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.