I have an iFrame that is 1024px X 700px. I removed the scrollbars using Scrolling="No" because the scrollbars don't look very pleasing to my eyes. I use javascript to scroll the iFrame but for the life of me, I cannot figure out how to detect if I'm already at the bottom of the iFrame. How can I detect if I'm at the end of the document in an iFrame so that I can scroll the parent window instead of the iFrame.
TLDR: If document position is at the bottom of the iFrame, I want to scroll the parent window.
<script type="text/javascript">
function handle(delta) {
var d=delta*-10;
window.scrollBy(0,d);
}
function wheel(event){
var delta = 0;
if (!event)
event = window.event; // For IE.
if (event.wheelDelta) {
delta = event.wheelDelta/120; // IE/Opera.
if (window.opera)
delta = -delta; // In Opera 9.
} else if (event.detail) {
delta = -event.detail/3; // Mozilla case.
}
if (delta) // If scrolling up, delta is positive. If scrolling down, delta is negative.
handle(delta);
if (event.preventDefault) // Ignore default mousewheel actions.
event.preventDefault();
event.returnValue = false;
}
if (window.addEventListener) // Continuously Listen For MouseScroll Events.
/** DOMMouseScroll is for mozilla. */
window.addEventListener('DOMMouseScroll', wheel, false);
window.onmousewheel = document.onmousewheel = wheel; // IE/Opera.
</script>