How to: set div scroll position on page load

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)
 
G

Guest

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
 
M

MLightsOut

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;
 
G

Guest

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top