심각한 도움이 필요합니다. 사용자가 스크롤 한 깊이에 따라 일부 그래픽에 애니메이션을 적용하기 위해 스크롤 이벤트 수신기를 사용하여 사이트를 프로그래밍했습니다.스크롤 이벤트 리스너가 iFrame의 iOS에서 작동하지 않습니다.
데스크톱 및 iOS에서 잘 작동합니다. 이 사이트를 iFrame에 삽입해야하는 경우에만 문제가 발생합니다. 데스크톱에서는 계속 작동하지만 iOS에서는 작동하지 않습니다.
나는 무슨 뜻인지 설명하기 위해 예제를 설정했습니다.
데스크톱에서이 페이지를 먼저 본 다음 iOS에서 봅니다. http://www.webzeile.com/iframescroll/index.html
고정 요소 (스크롤 오 미터) 아이폰 OS에 고정되지 않고, 나는 여기에 scrollTop를 얻을 수있는 기회가 없습니다.
메인 페이지 (내가 iframe이 여기에 속성을 수정할 수있는 기회가 없음)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>index</title>
<style type="text/css" media="screen">
html, body {
overflow-y:auto;
}
</style>
</head>
<body>
<div style="-webkit-overflow-scrolling: touch !important; overflow:auto; width:800px; height:500px; margin:0px auto;">
<iframe id="iframe" scrolling="auto" webkitallowfullscreen frameborder="0" style="width:100%; height:100%;" src="iframe.html"></iframe>
</div>
iframe이 내용
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>index</title>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<style type="text/css" media="screen">
html, body {
overflow-y:auto;
margin:0px;
padding:0px;
}
.div1, .div2 {
margin:0px;
padding:0px;
height:700px;
margin:0px;
position:relative;
width:100%;
}
.div1 {
background:green;
}
.div2 {
background:orange;
top:100%;
}
#scrollindicator {
color:#fff;
position:fixed;
right:20px;
top:20px;
z-index:1000;
width:150px;
height:25px;
}
</style>
</head>
<body>
<div class="div1">
<h1>Content 1</h1>
</div>
<div class="div2">
<h1>Content 2</h1>
<a href="#" onclick="alert($(window).scrollTop()); return false;">Alert scroll top</a>
<a href="#" onclick="alert(window.pageYOffset); return false;">Alert Y offset</a>
</div>
<div id="scrollindicator">
Scroll o meter: 0
</div>
<script type="text/javascript">
$(window).scroll(function() {
$("#scrollindicator").html("Scroll o meter: "+$(window).scrollTop());
});
</script>
</body>
</html>
시도 다. iOS에서 스크롤 핸들러를 사용할 수 없습니다. 어떤 아이디어?
This (http://stackoverflow.com/questions/18753367/jquery-live-scroll-event-on-mobile-work-around)가 도움이 될 수 있습니다. –
감사합니다. touchmove 이벤트가 발생했지만 scrollTop은 여전히 0입니다. –
@ChristophHeike 해결책이나 해결 방법을 찾았습니까? 나는 똑같은 문제에 직면 해있다. –