如何禁用滚动文档正文? [英] How to disable scrolling the document body?

查看:122
本文介绍了如何禁用滚动文档正文?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个HTML具有很多的内容和垂直滚动条只要HTML加载之后会出现。现在,从这个HTML全屏IFRAME被加载。问题是,当IFRAME被加载时,父母滚动条仍然存在,我想禁用滚动条时,该IFRAME被加载。

I have a HTML which has lot of content and a vertical scrollbar appears as soon as the HTML is loaded. Now from this HTML a full screen IFRAME is loaded. The problem is when the IFRAME is loaded, the parent scrollbar still persists, I want to disable the scrollbar when the Iframe is loaded.

我想:

  • document.body.scroll =无,它没有与FF和铬工作。
  • document.style.overflow =隐藏。在此之后我仍然能够滚动,整个IFRAME将向上滚动揭示父HTML
  • document.body.scroll = "no", it did not work with FF and chrome.
  • document.style.overflow = "hidden"; after this I was still able to scroll, and the whole iframe would scroll up revealing the parent HTML.

我的要求是,当IFRAME被加载时,我们应该永远无法滚动整个IFRAME如果父HTML有一个滚动条。

My requirement is, when the IFRAME is loaded, we should never be able to scroll the entire IFRAME if the parent HTML has a scrollbar.

任何想法?

推荐答案

如果你想使用的iframe的滚动条,而不是家长的使用这样的:

If you want to use the iframe's scrollbar and not the parent's use this:

document.body.style.overflow = 'hidden';

如果你想使用父母的滚动条,而不是iframe的,那么你需要使用:

If you want to use the parent's scrollbar and not the iframe's then you need to use:

document.getElementById('your_iframes_id').scrolling = 'no';

或设置滚动=不属性在iframe的标记:< IFRAME SRC =some_url滚动=不&GT ;。

or set the scrolling="no" attribute in your iframe's tag: <iframe src="some_url" scrolling="no">.

这篇关于如何禁用滚动文档正文?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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