Set Scroll Bar Position

They have: 82 posts

Joined: Oct 2001

I have an ASP page that always has different content.
I want the scroll bar always at the very bottom of the page.

I can set it if i use:

document.body.scrollTop=300

but it is not always 300

any ideas?

Please be browser independent.

Thanks!!!

- Mike

Blessed is the man who fears the LORD, who delights greatly in his commandments. Psalms 112:1

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

If you always have new content, wouldn't they be able to see that when they get to your page? Newest content at the top would assure that they would see it. And that's as cross-browser as possible!

It's also the easiest solution.

Other solutions, however, would be using cookies and scooting people to the right section based on where they were last. Someone else can help you with that. It's used a lot for bulletin boards.

Suzanne

They have: 82 posts

Joined: Oct 2001

Sorry maybe I was not clear enough.

It is for an asp chat app. The page does a refresh to display new messages. They are appended to the bottom
of the other messages. Consequently you have to scroll down to see the last post. I want the scroll bar postitioned so the last post is visible. The scroll bar should always be at the bottom of the page.

Thanks,

- Mike

Blessed is the man who fears the LORD, who delights greatly in his commandments. Psalms 112:1

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

Then the cookie solution and internal targets would be your best bet if you can't turn that around so the newest message is more logically at the top.

They have: 82 posts

Joined: Oct 2001

Is there not a way in Javascript or DHTML
(which I guess would not be browser independent)
to do the following

document.body.scrollTop=VeryUtmostLastPositionBottomofPage

Smiling

Thanks,

Mike

Blessed is the man who fears the LORD, who delights greatly in his commandments. Psalms 112:1

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

How about page anchors?

Do
Response.Write sPost
Loop 'Output all your posts
Response.Write "<a name='VeryUtmostLastPositionBottomofPage'>" 'create an anchor
'

And when the page refreshes, instead of going to just the page itself, make it go to page.asp#VeryUtmostLastPositionBottomofPage. Smiling

This way it reloads at the location of the anchor, which is always right after the last post.
I hope this is what you're asking about. Wink

Also, how do you refresh the page? I don't think this is possible if you use tags. Sad

detox's picture

They have: 571 posts

Joined: Feb 2001

Good call Abhishek. Just goes to show the simple solution is often the best!

They have: 2 posts

Joined: Dec 2001

There is actually a very simple solutuion:

Always works because if the value specified is greater than the page length then it gets set to the length of the page.

Build a better mousetrap, and a new improved mouse will come along and steal the cheese.

Cd&

They have: 82 posts

Joined: Oct 2001

Thanks CobolDinosaur!

I actually did this on Friday. I set it to some ridiculous number and it worked great. I appreciate your common sense solution.

Thank you very much,

- Mike

Blessed is the man who fears the LORD, who delights greatly in his commandments. Psalms 112:1

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Quote:
Good call Abhishek. Just goes to show the simple solution is often the best!

Guess there's always something simpler, eh? Sticking out tongue

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

I must point out that it only works if you set it to an obscenely large number. And that it is possible to have the page scroll that long (but likely it wouldn't). So it's not as reasonable a solution as inverting the entries.

Plus, lol, it doesn't work if JavaScript is disabled.

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Suzanne, all of the 6 or 7 ASP chat scripts that I know of use frames and javascript to the degree that none would be usable without enabling them. So I think it's safe to use the javascript method. Smiling

I gather that this is supposed to be not dissimilar to an instant messaging program? If so, then I don't think it'd be wise to break the standard of appending new messages at the bottom. Smiling

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

Ah, good point! Convention is important!

The purpose & audience are all important. I would wonder why you'd use this technology for a messaging system, but I'll shoosh now. Wink

S

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.