使用对象标签的PDF Viewer不适用于Edge [英] PDF Viewer using object tag not working for Edge

查看:137
本文介绍了使用对象标签的PDF Viewer不适用于Edge的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用object标签内联显示PDF文档-它在Chrome和Firefox中可以正常工作,但在Edge中不起作用.

I am trying to show a PDF document inline using the object tag - it works as expected in Chrome and Firefox but isn't working in Edge.

示例代码:

  <object id="pdfObj" data="http://www.pdf995.com/samples/pdf.pdf" type="application/pdf" target="_parent">
  </object>

柱塞: http://plnkr.co/edit/wH9ECcwkx3vHFv43xTo5?p=preview

在Edge中显示PDF查看器的好方法是什么?感谢您的帮助.

What's a good way to show the PDF viewer in Edge? Thanks for your help.

推荐答案

我遇到了类似的问题.对象标记在IE和EDGE中的行为有所不同;服务器需要接受由对象标记发出的HEAD请求(HEAD请求:仅在IE& EDGE中)并给出响应,然后发出get请求以提取文件. 这是Microsoft浏览器中的一个限制.

I've faced a similar issue. Object tag behaves differently in IE and EDGE; the sever needs to accept the HEAD request made by the object tag (HEAD request : only in IE & EDGE) and give a response, then a get request is made to fetch the file. This is a limitation in Microsoft's browsers.

如果我将具有data属性中url的url的html对象标记添加到dom中,而不是使用javascript设置已经存在的object标记的属性值,则这对我(EDGE和IE)也有效. dom.请注意,我有一个端点刷新响应,这将更新data属性的值.

Edit 1: This worked for me (EDGE and IE too) if I add the object tag html with the url in the data attribute to the dom instead of setting the attribute value, using javascript, of object tag which is already on the dom. Please note that I've a endpoint flushing response, this updates the value of data attribute.

这篇关于使用对象标签的PDF Viewer不适用于Edge的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆