【问题标题】:Is there a way to move an iframe scrollbar of a PDF from JS?有没有办法从 JS 移动 PDF 的 iframe 滚动条?
【发布时间】:2021-09-10 23:58:51
【问题描述】:

我试图从智能电视中可视化一些 PDF,所以我将使用一些不可见的按钮来上下滚动文档。

所有这些,必须在网络上,这是我尝试过的:

JS:

<script> 
function scrollUp(){
    alert("funcion llamada UP");
    window.scrollBy(0, -50);
}
function scrollDown(){
    alert("funcion llamada DOWN");
    document.getElementById('frame').contentWindow.scrollTo(10000,1000);
    window.getElementById('frame').scrollTo(50000, 20);
    //document.getElementById('frame').scrollTop = 438;
    //window.scrollBy(0, 50);
}

window.onload=inicio;   
function inicio(){
    document.querySelector("#boton").onclick=scrollUp;
    document.querySelector("#boton1").onclick=scrollDown;
}
    

PHP + HTML:

echo "<iframe src='$fichGG ' id='frame' class='frame' width=\"100%\" style=\"height:100%\"></iframe>";

警报有效,但 getElement 或 scrollBy 的所有选项都不起作用,不知道为什么。

谢谢大家。

【问题讨论】:

    标签: javascript php html iframe


    【解决方案1】:

    这就是你要找的东西.....document.getElementById('div_iframe').scrollTop = 500 500 是向下滚动多少像素,是的,这是 JS。

    【讨论】:

    • 您好CodeMaster,感谢您的回复,我试过了,还是不行,我得再想想办法。
    猜你喜欢
    • 2015-11-01
    • 2012-05-16
    • 2011-09-06
    • 2019-06-26
    • 1970-01-01
    • 2020-04-28
    • 2011-09-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多