window.scrollTo

S

sri_san

Hi All,
I am working on a script to find the position of a element and
scroll to the element on postback. Here is what I came up with ..

---------------------------------------
function getAbsoluteTop(objectId) {
// Get an object top position from the upper left viewport corner
// Tested with relative and nested objects
o = document.getElementById(objectId);

oTop = o.y ? o.y : o.offsetTop; // Get top position from
the parent object
while(o.offsetParent!=null) { // Parse the parent hierarchy up to the
document element
oParent = o.offsetParent // Get parent object reference
oTop += o.y ? o.y : oParent.offsetTop; // Add parent top position
o = oParent
}
// Return top position
return oTop
}


function scrollElement()
{
var y = getAbsoluteTop('test');

window.scrollTo(1,y);

}
-----------------------------------------

Works fine in Firefox but doesnt in IE6/7. Could anyone point out
what am i missing?

Thanks,
Sam.
 

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

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top