gpt4 book ai didi

javascript - 如何从 iframe 内 scrollTop iframe 外的跨度

转载 作者:行者123 更新时间:2023-11-27 22:36:42 29 4
gpt4 key购买 nike

我的网站附属于另一个网站 iframe。

托管网站在带有滚动条的跨度内获得固定高度的 iframe(不要问为什么)。

我正在寻找一种从 iframe(我的网站所在的位置)内更改跨度滚动(使用 JS)的方法。

我知道这是可以做到的,因为我将 JqueryUI 对话框与 position:top (在 iframe 内)一起使用

将 span 滚动到顶部(在 iframe 之外)

HTML:

<body style="overflow:hidden;">
<span style="float: left; height:488px; overflow-y:auto;">
<table>
<tr>
<td>
<iframe id="Iframe" name="Iframe" src="Login.aspx"
width="775px" height="4000px"></iframe>
</td>
<td style="width: 200px; height: 600px; font-size: 25px; border: 1px solid #000000;" valign="top">Side Bar</td>
</tr>
</table>

</span>

最佳答案

window.parent.$("span").whateverYouWantToDo();

仅当 iframe 内容与主窗口位于同一域时才有效。

当有不同的域时您只能从主窗口捕获加载事件。尝试对此使用react。看看你能做什么

文档.location.hash

它可能可以从主窗口访问,但不能跨浏览器访问

关于javascript - 如何从 iframe 内 scrollTop iframe 外的跨度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2310054/

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