I'm using an iframe to load an external URL. Here's the structure -
<iframe id="iframe-wrapper" src="http://blog.kpmg.ch/" style="width: 100%; height: 100%; overflow-y: scroll"></iframe>
I'm trying to do something when I scroll through the iframe contents. I tried various ways, nothing worked. Here are some things I tried already -
1) jQuery iframe scroll event (IE)
$(window).load(function(){
$($('#iframe-wrapper').contents()).scroll(function(){
alert("Scrolling");
});
});
2) jQuery iframe scroll event (IE)
$('#iframe-wrapper').load(function(){
$($(this)[0].contentWindow).scroll(function(){
alert("Scrolling");
});
});
$("#iframe-wrapper").load(function(){
var iframeContent = getFrameTargetElement( document.getElementById("iframe-wrapper") );
iframeContent.onscroll = function(e){
alert("Scrolling");
};
});
4) Jquery and binding an event to an iframe
$("#iframe-wrapper").load(function(){
$("#iframe-wrapper").contents().find("body").scroll( function(e) {
alert("Scrolling");
});
});