Forum Moderators: open
I would like to popup an alert box which is a div, rather than a new window. My only problem is with pages that are deep enough to cause the browser to create a vertical scroll bar because in order to get my div on the visible viewport I need to know how far the page is currently scrolled - eg the y coord of the viewport.
One sees behaviour out there that suggests this is quite possible, but it seems like difficult info to get hold of.
Any ideas?
tia
tony
Use it like this:
var myDiv = document.getElementById( "scrolling_div");
alert( myDiv.scrollTop);
In your case I imagine you can do:
alert( document.body.scrollTop);
Not sure on the browser compatibility on this though, I know it works in IE, pretty sure it works in FF, not sure about anything else though.