[已解决]禁用正文/HTML滚动 [英] [SOLVED] Disabling Body / HTML Scrolling

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

问题描述

这里有些奇怪的情况,我使用内容编辑器将iframe嵌套在垂直滚动的div中.当您到达div的末尾时,向下滚动页面的其余部分就会开始滚动,因此基本上我正在尝试防止这种过度滚动".

Got a bit of a strange situation here, I'm using a Content Editor to nest an iframe within a div that scrolls vertically. When you reach the end of the div scrolling down the rest of the page starts to scroll, so basically I'm trying to prevent that "over-scrolling". 

尝试通过JavaScript和Jquery进行各种不同的功能均无济于事,当它只是div中的文本时,我可以使它工作,但是当iframe在其中时,我无法使它工作.最简单的解决方案似乎只是设置html和body 用JavaScript溢出到隐藏的位置,但出于任何原因我都无法做到.

Tried all sorts of different functions via JavaScript and Jquery to no avail, I can get it to work when it is just text in a div but I can't get it to work when the iframe is in there. The most simple of solutions seemed to just be setting html and body overflow to hidden with JavaScript but for whatever reason I can't. 

最重要的是,我正在寻找一种方法来防止鼠标在div/iframe中时主体滚动.

Bottom line, I'm looking for a way to prevent the body from scrolling when the mouse is in the div/iframe. 

有什么想法吗?

推荐答案

我认为您无法做到这一点.

I don't think you can do this.

这是Web浏览器的默认行为.

It is a default behavior for web browser.


这篇关于[已解决]禁用正文/HTML滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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