gpt4 book ai didi

javascript - jquery - 如何使窗口区域滚动和 iframe 也同时滚动?

转载 作者:行者123 更新时间:2023-11-28 10:59:05 25 4
gpt4 key购买 nike

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

下面是我的代码,但无法工作

$(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.

关于javascript - jquery - 如何使窗口区域滚动和 iframe 也同时滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11915949/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com