0

Possible Duplicate:
Changing Scrollbar Position

I have a div that will act like an image browser

<div style="width:100%; height:500px; overflow:auto;">
    <img src="myimage.jpg" alt="news" style="width:100%;height:auto;"/>
</div>

if my image is 1200px in height, is there anyway that i can predefine the scrolling position of the image? basically scroll to the middle part of the image when the page loads

i'm not looking for an jQuery scrolling animation plugin. I want the page to load with the image already scrolled to a specific position.

my main audience would be using various versions of IE....(> IE7)

Community
  • 1
  • 1
tom91136
  • 8,662
  • 12
  • 58
  • 74

2 Answers2

2

jQuery

$('#foo').scrollTop(500);

Pure JS

 document.getElementById('foo').scrollTop = 500; // (working with IE6+)

More information find here:

Peter
  • 16,453
  • 8
  • 51
  • 77
1

use scrollTo(0, window height * 0.5); or if you need you can calculate the current div's center relative to the page offset.

Chris
  • 404
  • 4
  • 13