【发布时间】:2014-04-09 02:52:20
【问题描述】:
我正在尝试使用 fancybox 来显示 pdf,但我没有成功。
我已经在使用 fancybox 来显示一个 div 内容,但现在我也在尝试使用 fancybox 在里面显示一个 pdf。
我正在尝试打开保存在计算机上的 pdf 文件,其方式与我在 fancybox 中显示内容的方式相同,但无法使用 pdf。
我的 html 中有一些带有href="#show" 的链接指向我的<div id="show">,并且这些链接也有class="buttonl",这是我在我的jQuery 脚本中用来打开fancybox 的类。
喜欢这里:<a href="#show" class="buttonl" >Title of my first post</a><br />
有人已经使用fancybox来显示pdf可以给我一些帮助吗?
我的代码:
http://jsfiddle.net/ritz/WAKdB/1/
我的 jQuery:
$(document).ready(function() {
$("a.buttonl").fancybox({
maxWidth : 800,
fitToView : false,
width : '70%',
height : '70%',
autoSize : false,
closeClick : false,
openEffect : 'elastic',
closeEffect : 'elastic'
});
})
我的html:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<article id="loop-news">
<h2>
<a href="#show" class="buttonl" >Title of my first post</a><br />
</h2>
<span>Tuesday<strong>,</strong> 8 April 2014</span>
<p>My first post content is this!</p>
<a class="buttonl" href="#show"> Read more</a>
<div id="show">
<h2>IM the fancybox content!!</h2>
</div>
</article>
<hr>
<article id="loop-news">
<h2>
<a href="#show" class="x">Post with pdf</a><br />
</h2>
<span>Tuesday<strong>,</strong> 8 April 2014</span>
<p>My first post with pdf!</p>
<a class="buttonl" href="#show"> Read more</a>
<div id="show">
<a href="../design_multimedia_method.pdf"></a>
</div>
</article>
【问题讨论】:
-
你必须以
iframe打开它,检查jsfiddle.net/RHaAX from fancyapps.com/fancybox/#examples No.15 -
好吧,引用的文档被移动了,但是试试这个jsfiddle.net/SQSFp
-
感谢您的回答,但是我的本地机器上不能有 pdf 文件?我需要在服务器中托管我的 pdf 文件吗?
-
Opps,我现在测试了,我发现我可以用这个方法从我的本地机器打开一个pdf!谢谢肯尼迪 :)
-
我猜没有滚动条是不可能的。我会在 Linux 上使用 unoconv Libreoffice 将 pdf 转换为图像。然后您可以将高分辨率图像添加到您的滑块
标签: jquery pdf plugins fancybox fancybox-2