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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,084
Latest member
HansGeorgi

Latest Threads

Top