scrollPosition = window.frames[id].document.body.scrollTop;
The above co开发者_如何学Cde doesn't work correctly. Please tell me how to correct it.
To get scrollTop in a crossbrowser way jQuery does this:
function GetScrollTop()
{
var doc = document.documentElement
var body = document.body;
return ((doc && doc.scrollTop) || (body && body.scrollTop || 0)) - (doc.clientTop || 0);
}
I personally use simply this:
return document.documentElement.scrollTop || document.body.scrollTop
If the frame's document is located on a different domain, you will not be able to access most properties and objects on it due to the same origin policy.
Well, I think that what you're looking for is easy obtainable if you're using jQuery. So that might be worth looking into?
http://api.jquery.com/scrollLeft/ there is also scrollTop (api.jquery.com)
精彩评论