1

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>
4

1 回答 1

-1
 <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.
于 2012-08-11T15:39:49.347 回答