Firefox中的Fancybox PDF问题

时间:2012-01-10 16:00:49

标签: firefox pdf popup fancybox

我设置了Fancybox,以便当用户点击pdf链接时,它会弹出显示pdf,但是在Firefox中它会询问您是要保存还是打开文件而我不想这样做。如何强制pdf显示在fancybox弹出窗口中?它适用于Safari。

<a class="pdf" href="http://www.test.co.u.uk/test.pdf">test.pdf</a>

$(".pdf").fancybox({
   'width' : '700',
   'height' : '700',
   'autoScale' : true,
   'transitionIn' : 'none',
   'transitionOut' : 'none',
   'type' : 'iframe'
});

4 个答案:

答案 0 :(得分:2)

就个人而言,我只想使用Google文档在iframe中显示PDF。它会自动调整PDF大小以匹配iframe尺寸。以下是要使用的格式:

<iframe src="http://docs.google.com/gview?url=http://samplepdf.com/sample.pdf&embedded=true" style="width:100%; height:100%;" frameborder="0"></iframe>

您不需要闪光灯或任何其他插件。

答案 1 :(得分:0)

我会将PDF文件转换为HTML,或尝试将PDF转换为图像。

我遇到了这个问题,但我无法更改服务器设置以显示PDF文件,而不是提示下载。

浏览器与阅读PDF文件的方式也存在差异。

答案 2 :(得分:0)

除非用户有安装了PDF的插件,否则PDF不会在Firefox中呈现内联。它不是Firefox本身支持的格式。

答案 3 :(得分:0)

最有可能的是,您没有在Firefox中安装pdf插件或插件崩溃。

在Firefox中,转到Tools - &gt; Add-ons - &gt; Plugins并在列表中查找Adobe Acrobat PDF插件。如果不存在,check this将学习如何安装(或重新安装)。

此外,还有一种更好的方法可以使用除iframe以外的fancybox打开PDF文件,因此对于这个html:

<a class="pdf" href="http://www.test.co.u.uk/test.pdf">test.pdf</a>

您可以使用此脚本:

$(document).ready(function() {
 $(".pdf").click(function() {
  $.fancybox({
   'width': '70%', // or whatever
   'height': '90%',
   'autoDimensions': false,
   'content': '<embed src="'+this.href+'#nameddest=self&page=1&view=FitH,0&zoom=80,0,0" type="application/pdf" height="99%" width="100%" />',
   'onClosed': function() {
     $("#fancybox-inner").empty();
   }
  });
  return false;
 }); // pdf 
}); // ready

我从May 2010

开始为Fancybox v1.3.x推荐这种方法

请注意我设置了height =“99%”。如果您使用HTML5 DCTYPE,它将避免双垂直滚动条。这是因为HTML5初始化了边距。

<强>更新即可。 顺便说一句,整数值没有qoutes所以

'width' : '700',
'height' : '700',

应该是

'width' : 700,
'height' : 700,

它会为您节省一些麻烦,主要是使用IE