Set the scrollbar to the bottom after reloading an IFRAME
Posted: Sat Oct 25, 2003 8:43 am
I'm writing a chat script (mostly for my own learning purposes since I know there are a ton of them out there) and I'm using several IFRAME objects to handle the different sections of the chat. One IFRAME points to a PHP file which displays all the chat text which has been typed.
When the user enters new text, another invisible IFRAME is run which posts the message to the database, and then the IFRAME containing the transcript is reloaded. I do all this via JavaScript as outlined below:
Now, when the transcript iframe is reloaded, the scrollbar is always at the top most position. How can I make this so upon reload, it positions the scrollbar at the bottom of the iframe?
When the user enters new text, another invisible IFRAME is run which posts the message to the database, and then the IFRAME containing the transcript is reloaded. I do all this via JavaScript as outlined below:
Code: Select all
function sndMessage(usrId) {
window.frames.runphp.location.href = 'sendmsg.php?user_id='+usrId+'&msgtxt='+document.postmsg.msgtxt.value;
window.frames.winTalk.location.href = 'talk.php';
document.postmsg.msgtxt.value = '';
document.postmsg.msgtxt.focus;
return false;
}