如何禁用滚动文档正文?文档、正文

由网友(华灯下,我们的爱已成陌路)分享简介:我有一个HTML具有很多的内容和垂直滚动条只要HTML加载之后会出现。现在,从这个HTML全屏IFRAME被加载。问题是,当IFRAME被加载时,父母滚动条仍然存在,我想禁用滚动条时,该IFRAME被加载。I have a HTML which has lot of content and a vertical sc...

我有一个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">.

阅读全文

相关推荐

最新文章