如何在处理程序中自动滚动到 iframe 的中心?

发布于 2024-12-01 16:20:10 字数 385 浏览 2 评论 0原文

我有这个代码

<a href="index.php?option=com_surveys&amp;Itemid=120&amp;act=view_survey&amp;survey=1:basic-survey" class="modal" rel="{handler: 'iframe', size: {x: 680, y: 500}}">Click here</a>​

,我需要使用这个代码,没有办法绕过它。我疯狂地寻找一种方法让此代码将 iframe 滚动到页面中间。请帮忙。我从未在处理程序中使用过 iframe 并使用过这样的模态类,我不知道参数将去往何处,甚至不知道参数将去往何处。我尝试了一些但没有成功。

谢谢

I have this code

<a href="index.php?option=com_surveys&Itemid=120&act=view_survey&survey=1:basic-survey" class="modal" rel="{handler: 'iframe', size: {x: 680, y: 500}}">Click here</a>​

and i need to use this code, no way around it. i have gone crazy looking for a way to make THIS CODE scroll the iframe to the middle of the page. please help. I never used an iframe within a handler and using the modal class like that, i don't know where the parameters will go, or even what parameter will go. i tried a few with no success.

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

与他有关 2024-12-08 16:20:10

您的问题不清楚......您是否需要通过单击按钮滚动到页面上的某个点?如果是这样,请使用scrollWindow/scrollTo函数,例如:

<html>
<head>
<script type="text/javascript">
function scrollWindow()
{
window.scrollTo(100,500);
}
</script>
</head>
<body>

<input type="button" onclick="scrollWindow()" value="Scroll" />
<p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p>

</body>
</html>

如果要将iframe对齐到中心,请使用表格,例如:

<body> 
<table width="100%" height="100%"> 
  <tr align="center"> 
    <td align="30px"> 
         <div id="iframe" style="position:relative;overflow:hidden;width:100%; height:100%;">
         Insert iframe code here</div>

    </td> 
  </tr> 
</table> 

</body>

You're question is unclear....do you need to scroll to a point on the page with the click of a button? If so use to scrollWindow/scrollTo function, e.g.:

<html>
<head>
<script type="text/javascript">
function scrollWindow()
{
window.scrollTo(100,500);
}
</script>
</head>
<body>

<input type="button" onclick="scrollWindow()" value="Scroll" />
<p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p>

</body>
</html>

If you want to align the iframe to the centre, use a table, e.g.:

<body> 
<table width="100%" height="100%"> 
  <tr align="center"> 
    <td align="30px"> 
         <div id="iframe" style="position:relative;overflow:hidden;width:100%; height:100%;">
         Insert iframe code here</div>

    </td> 
  </tr> 
</table> 

</body>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文