繁体   English   中英

jQuery-如何同时在窗口区域和iframe scrll中滚动?

[英]jquery - How to make scroll in window area and iframe scrll too at the same time?

jQuery-如何同时在窗口区域和iframe scrll中滚动?

下面是我的代码,但不能正常工作

$(window).scrollTop() = $('body iframe').scrollTop();

例如: http//i.imgur.com/1gfhi.png

<html><head><title></title>
<script src="jquery-1.7.2.js" type="text/javascript"></script>
<script type="text/javascript">
 $(window).scrollTop() = $("body iframe").scrollTop();
 $(window).scrollLeft() = $("body iframe").Left();
</script>
<style type="text/css">
 .header{
    position: absolute;
left: 100px;
top: 0px;
background-color: black;
width: 1000px;
height: 100px;
 }
 .iframecontent{
position: absolute;
left: 100px;
top:100px;
 }
 .footer{
position: absolute;
left: 100px;
top: 500px;
background-color: green;
width: 1000px;
height: 100px; 
 }  
</style>
</head><body>
<div class="header"></div>
<iframe class="iframecontent" src="iframecontent.html" scrolling="auto"></iframe>
<div class="footer"></div>
</body></html>
 <script src="jquery-1.7.2.js" type="text/javascript"></script>

 <script type="text/javascript">
 $(window).scrollTop() = $("body iframe").scrollTop();
 $(window).scrollLeft() = $("body iframe").Left();
 </script>

 use this script in iframecontent.html.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM