Life Moves On

My Experience With Technology

Tuesday, March 17, 2009

Scroll 'div' to the bottom

If you would like to move your scroll to the bottom of a div, use the following code on page load function. This is very handy when you would like to create chat windows where the chat log div should always scrolled down to bottom to see the latest chat dialogs


body onload="document.getElementById('testdiv').scrollTop = document.getElementById('testdiv').scrollHeight"


This assumes that id of the div you want to work with has is "testdiv".

Labels: ,

Monday, March 09, 2009

Changing the background image of an element on mouseover

If you would like to change the background image of any element using javascript use the following code on the same tag

onmouseover="this.style.background='url(images/home2.gif) no-repeat';" onmouseout="this.style.background='url(images/home1.gif) no-repeat';"

Labels: , ,