gpt4 book ai didi

javascript - 使用 JavaScript 滚动 PDF

转载 作者:行者123 更新时间:2023-12-02 15:33:00 26 4
gpt4 key购买 nike

我发现了类似的问题Scroll PDF embedded in HTML但没有看到答案。有人对如何操作 iframe 中显示的 PDF 有任何建议吗?与上一篇文章链接类似,我尝试在 iframe 没有焦点(主页有焦点)时滚动 PDF。

谢谢!

最佳答案

实际上您提供的链接中有答案:

Hardly.

What you might be able to do is to put the iframe into a div with overflow: auto, and give the iframe a very large height value so the containing PDF is at full size. Make the surrounding div less tall than the iframe. When your buttons get clicked, scroll the surrounding div.

I haven't tested it so there may be some snag on the way, but this could work - and is probably the best you can do.

~Pekka 웃

这很容易。这就是你要做的:

这取决于 iframe 是否是“外部”的,而不是来自您的服务器。就说它是外包的

代码

<div id="iframeContainer" style="width: 800px; height: 600px; overflow: auto;">
<iframe width="1800" height="6000" src="yourPDFfileSRC" scrolling="no">
</iframe>
//You have to know exact width and height of PDF file
</div>

 

<script type="text/javascript">
$("document").ready(function()
{
$("#iframeContainer").scrollTop(1400);
});
</script>

奖金

你可以像这样设置动画:

<script type="text/javascript">
$("document").ready(function()
{
$("#iframeContainer").animate({scrollTop: 1400}, 500); //500 - time of animation
});
</script>

关于javascript - 使用 JavaScript 滚动 PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33154598/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com