javascript - 如何使用浏览器的滚动条滚动 iframe 的内容?

标签 javascript jquery html css iframe

我创建了一个由 iframe 组成的网页。我想使用浏览器滚动条滚动 iframe 内容。这是我的代码:

<html>
    <head>
        <script src = "jquery-2.1.4.min.js">
        </script>
        <script src = "iframe.js">
        </script>
        <style>
            button{
                position : relative;
            }
        </style>
    </head>
    <body>
        <div class = "frame">
            <iframe src = 'demo.html' id = "sd" frameBorder='0' scrolling = "no" height = "100%" width = '100%'>
            </iframe>
        </div>
            <button id ="zoomIn">
                zoom in
            </button>
    </body>
</html>

单击 zoomIn 按钮时,我希望 iframe 中的内容增加其大小。 iframe 中不应有任何滚动条,但滚动应由浏览器完成。

最佳答案

<iframe src = 'demo.html' id ='sd' frameBorder='0' scrolling = 'no' height = '100%' width = '100%'>

在你的 CSS 中

iframe { overflow:hidden; }

关于javascript - 如何使用浏览器的滚动条滚动 iframe 的内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30707626/

相关文章:

javascript - 将 create-react-app 从 javascript 迁移到 typescript

javascript - 对这种行为感到非常困惑(返回数组的唯一元素的简单函数)

javascript - 阻止 jQuery 单击后函数继续执行

css - 创建相对于父 div 的绝对输入文本

javascript - 链接在图像描述中不起作用

javascript - 表单验证器检查选项并选择检查不起作用

javascript - jQuery 定时动画点击

javascript - 带有 this/bind 的 JS 原型(prototype)范围

python - 可以阻止 Genshi 解析 HTML 实体吗?

php - 简单的 mysql 选择和插入不起作用