iframe을 사용하여 외부 URL을로드하고 있습니다. 구조는 다음과 같습니다 -iframe에 스크롤 이벤트 바인딩
<iframe id="iframe-wrapper" src="http://blog.kpmg.ch/" style="width: 100%; height: 100%; overflow-y: scroll"></iframe>
iframe 내용을 스크롤 할 때 뭔가를하려고합니다. 나는 여러 가지 방법을 시도했지만 아무 것도 효과가 없었다.
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
,691 - 여기에 내가 이미 시도 몇 가지 있습니다$("#iframe-wrapper").load(function(){
$("#iframe-wrapper").contents().find("body").scroll(function(e) {
alert("Scrolling");
});
});
'$ ("if iframe-wrapper"). scroll (fn);'시도해 보셨습니까? – Jai
복제물은 본 적이 없거나 시도 되어도 작동 할 수있는 것이 아닙니다! 나는 이미 링크를 시도했다. 내가 보여준 세 번째 예를 확인하고 내가 잘못한 곳을 기쁘게 할 수 있다면 나를 도울 것이다. 전체 질문을 읽고 이해하기 전에 중복 된 것을 찾지 마십시오. :) – Shuvro
@Jai, 그래, 나는 그것을 벌써 시도했다, 나를 위해 일하지 않았다. 나는 여기서 무엇이 잘못 될지 모른다. iframe이 완전히로드 된 후 이벤트가 바인딩되어야하는 곳을 발견했습니다. 그래서 나는 그런 식으로 시도하지 않았다. – Shuvro