如何防止页面在加载时滚动到iframe? [英] How to prevent page from scrolling to an iframe on load?

查看:147
本文介绍了如何防止页面在加载时滚动到iframe?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的页面中有一个iframe,当我加载页面时,页面滚动到iframe的开头,距离页面顶部约200px。如果我将iframe更改为div,则页面加载正常,这意味着页面将滚动到顶部。因此,iframe导致了这种情况。

I have an iframe in my page and when I load the page, the page scrolls to the start on the iframe which is about 200px from the top of the page. If I change the iframe to a div then the page loading is as normal, meaning the page is scrolled to the top. So it is something about the iframe that is causing this.

有谁知道如何防止这种情况发生?

Does anyone know how to prevent this from happening?

推荐答案

抱歉,这是一个愚蠢的问题。我只是将style属性设置为 display:none; 并解决了这个问题。

Sorry, this was a dumb question. I just set the style property to display:none; and that solved it.

这篇关于如何防止页面在加载时滚动到iframe?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆