【问题标题】:Fancybox PDF issue in FirefoxFirefox 中的 Fancybox PDF 问题
【发布时间】:2012-01-10 16:00:48
【问题描述】:

我设置了 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'
});

【问题讨论】:

    标签: firefox pdf popup fancybox


    【解决方案1】:

    就个人而言,我只会使用 Google Docs 在 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>
    

    您不需要 flash 或任何其他插件。

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        【解决方案3】:

        很可能,您没有在 Firefox 中安装 pdf 插件,或者该插件刚刚崩溃。

        在 Firefox 中,转到 Tools --> Add-ons -->Plugins 并在列表中查找 Adob​​e 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

        【讨论】:

          【解决方案4】:

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

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

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

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2013-08-28
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2011-10-11
            • 2013-07-24
            相关资源
            最近更新 更多