How to: set div scroll position on page load

  • Thread starter Thread starter Mel
  • Start date Start date
M

Mel

Is there a way to set the scroll position of a DIV control to the
bottom when the page loads? I was hoping to implement this in my
exising Page_Load event in my aspx.vb code behind.

(using asp.net 2.0, vb.net 2005)
 
Is there a way to set the scroll position of a DIV control to the
bottom when the page loads?  I was hoping to implement this in my
exising Page_Load event in my aspx.vb code behind.

(using asp.net 2.0, vb.net 2005)

You need to use javascript to do it. Add to <body> tag onload event

onload="document.getElementById('DIV1').scrollTop =
document.getElementById('DIV1').scrollHeight;"

where DIV1 is id of your control
 
You need to use javascript to do it. Add to <body> tag onload event

onload="document.getElementById('DIV1').scrollTop =
document.getElementById('DIV1').scrollHeight;"

where DIV1 is id of your control

Thanks that worked.

My aspx code:
function set_scroll_pos()
{
document.getElementById
('divgvnotes').scrollTop=document.getElementById
('divgvnotes').scrollHeight;
}

window.onload=set_scroll_pos;
 
Thanks that worked.

My aspx code:
    function set_scroll_pos()
    {
        document.getElementById
('divgvnotes').scrollTop=document.getElementById
('divgvnotes').scrollHeight;
    }

     window.onload=set_scroll_pos;

well, it's pure javascript code (not an aspx)
 
Back
Top