Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-30-2004, 10:44 PM   PM User | #1
NL_Fred
New Coder

 
Join Date: Oct 2003
Location: The Netherlands
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
NL_Fred is an unknown quantity at this point
positioning in iframe page

Hello

I am building a small messenger and I am using three iframes. One for displaying the messages and one for entering the messages and one hidden iframe for polling.

I want the lines in the display window to scroll up and than position at the bottom (so the last message is at the last line and visible)

How do I do that? (I dont want to use the <A name=... Anchor for jumping to the bottom after reloading the display window.)
__________________
Fred
NL_Fred is offline   Reply With Quote
Old 06-30-2004, 10:52 PM   PM User | #2
sad69
Senior Coder

 
Join Date: Feb 2004
Posts: 1,206
Thanks: 0
Thanked 0 Times in 0 Posts
sad69 is an unknown quantity at this point
You can try using the scrollTo() method:
http://www.devguru.com/Technologies/..._scrollto.html

The next question may be: what values do I pass to scrollTo() (like where's the bottom going to be necessarily?)

I'm not too sure how it would work, but my guess might be to find out how big the body area is, and then scroll to that Y-value. Just my guess, I've never tried it..

Mess around with it and see if you can get it to go. Perhaps in the meanwhile someone with the knowledge can advise you better.

Good luck,
Sadiq.
sad69 is offline   Reply With Quote
Old 06-30-2004, 11:02 PM   PM User | #3
dumpfi
Regular Coder

 
Join Date: Jun 2004
Posts: 565
Thanks: 0
Thanked 18 Times in 18 Posts
dumpfi will become famous soon enough
You could use window.innerHeight / document.body.offsetHeight in conjuction with window.scrollTo(), e.g.:

if(document.all) window.scrollTo(0, document.body.offsetHeight);
else window.scrollTo(0, window.innerHeight);

Note: You can use this only if the body-tag was already loaded so it would make sense to start the execution of the function with the onload-event.

Last edited by dumpfi; 06-30-2004 at 11:07 PM..
dumpfi is offline   Reply With Quote
Old 07-01-2004, 07:15 AM   PM User | #4
NL_Fred
New Coder

 
Join Date: Oct 2003
Location: The Netherlands
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
NL_Fred is an unknown quantity at this point
The option Sad69 offered suited best for me. I've build this small function which runs at onload.

function toBottom() {
self.scrollTo(0, 9999999)
}

It works fine with ie6 do some of you expect problems with other browsers?
__________________
Fred
NL_Fred is offline   Reply With Quote
Old 07-01-2004, 09:16 AM   PM User | #5
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
I think this is better:

function toBottom() {
self.scrollTo(0, document.body.scrollHeight);
}
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 07-02-2004, 12:08 PM   PM User | #6
NL_Fred
New Coder

 
Join Date: Oct 2003
Location: The Netherlands
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
NL_Fred is an unknown quantity at this point
Thank you I also like this better.
__________________
Fred
NL_Fred is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:32 PM.


Advertisement
Log in to turn off these ads.