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>

Solved it myself.. I can now scroll parent windows when the iFrame has reached the bottom.. Tested and works in all browsers:

FF, Opera, IE, Safari, Chrome. Thanks anyway though. Always a pleasure to post on Daniweb.com

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(scrollHeight == document.body.scrollHeight)	//  If at the bottom of the frame page, scroll parent window.
	{
		window.parent.parent.scrollBy(0,20);
	}

	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.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.