I'm using the following event to detect if the bottom of a page is reached when scrolling :
$(window).scroll(function() {
if($(window).scrollTop() == $(document).height()-$(window).height())
alert('Bottom reached');
}
});
This works fine on a normal page, but now I want this to work on a page that is inside an iframe. This event must be declared inside the page in the iframe.
But window
points to the page that contains the iframe, so I can't use that.
Any ideas?
var currAgreementTab = this.get('parentController').get('currAgreement');
var contractContainer = Ember.$('div#marginContractContainer');
var iframe = contractContainer.children(currAgreementTab.element)[0].contentWindow;
if (iframe) {
iframe.onscroll = function() {
var scrolledHeight = Ember.$(iframe).height() === Ember.$(iframe.document).innerHeight() ? Ember.$(iframe).height() : Ember.$(iframe.document).innerHeight() - Ember.$(iframe).height();
if (Ember.$(iframe).scrollTop() === scrolledHeight) {
var currAgreementTab = that.get('parentController').get('currAgreement');
Ember.set(currAgreementTab, 'checkDisabled', false);
}
}
}