javascript - 当您的手指在 iframe 上方时垂直滚动页面
问题描述
我有一个带有scrolling: no
选项的 iframe。对于所有移动设备,我想在 iframe 上滚动,换句话说,当我使用手指在 iframe 上垂直向下滚动时,父页面此时不会滚动。
提前致谢。
解决方案
如果您使用手机,则添加滚动,否则设置“否”
var iframe = document.querySelector("iframe");
if (/Android|webOS|iPhone|iPod/i.test(navigator.userAgent)) {
iframe.setAttribute("scrolling", "yes");
} else {
iframe.setAttribute("scrolling", "no");
}
<iframe src=""></iframe>
推荐阅读
- java - 监控 jms 消息的工具
- java - 在java中读取和格式化数据
- laravel - 得到一个“请确保 PHP Redis 扩展已安装并启用。” 尽管加载了扩展程序,但仍出现错误
- python - Django ckeditor 上传图片
- android - android - 膨胀类 android.support.design.internal.BottomNavigationView 时出错
- c++ - 是否可以在不指定模板类型的情况下检查对象是否等于模板类?
- python - 编写一个程序,告诉用户他们什么时候满 64 岁
- python - 使用字典从数据框中选择多列
- masstransit - 佐贺的 MassTransit In-Memory Outbox
- javascript - 访问组件 hoc 外部的道具 - 启动暗色实现