imgpdf展示_如何显示图像(img)或pdf(iframe)?

更新时间:2023-05-05 17:43:38 阅读: 评论:0

imgpdf展⽰_如何显⽰图像(img)或pdf(iframe)?我在页⾯上显⽰的动态链接(其余部分)可能会导致jpeg,tif或pdf⽂件在响应中。如何显⽰图像(img)或pdf(iframe)?
我试图做这样的(图像部分⼯作正常):
fetchContent(uri){
$.ajax({
type: "GET",
url: uri,
success: function(output, status, xhr) {
var contentType = ResponHeader("Content-Type");
if(contentType === "image/jpeg" || contentType === "image/tiff"){
// IMG: get parent div 'container'
var $container = $('#container', top.frames["content"].document);
var img = new Image();
$(img)
.load(function(){
// initially hide
$(this).hide();
$(this).attr('id', 'imgId');
// parent div:
$container
// remove previous image
.empty()
// add this image
.
append(this);
// fade in image effect
$(this).fadeIn();
})
// t the src attribute of the new image to our image
.attr('src', uri);
}el if(contentType === "application/pdf"){
// PDF: get parent div 'main'
var $main = $('#main', top.frames["content"].document);
$pty();
$main.append("");
}
},
complete: function(output){
$('#navigation-block').append(output);
},
error: function(output) {
$('#navigation-block').append(output);
}
});
}
的PDF部分不⼯作。
我该如何分类?
顺便说⼀句,我控制REST服务器端和jQuery端,所以我在REST响应头中添加了正确的内容类型。
我检出了PDF.js并且会使⽤它,但我的客户不幸使⽤了IE8。
感谢
+1
到底会发⽣什么(或者没有按”当它是⼀个PDF?你的iFrame是否显⽰,你可以⽤“你好”来测试它。⾃然从你的浏览器打开PDF⽂件,从其他⽹站说?因为您的PDF可以在阅读器中打开页⾯或在独⽴阅读器应⽤程序中打开。 –
+0
对不完整的帖⼦感到抱歉,但我不确定会发⽣什么情况,因为成功回调永远不会被调⽤。当我调试jQuery时,我发现它导致某种“⽆传输”错误。我不完全知道如何在ajax请求中介⼊(设置断点),以便我可以看到发⽣了什么?整个阿贾克斯块被踩过了。这有什么窍门吗? –
+0
它的⼯作原理!也许这是跨域问题。出于测试⽬的,该患者(我)使⽤来⾃某个随机⽹站的PDF URL。在我的REST服务中添加pdf⽀持后,它开始⼯作。
⽆论如何,谢谢。 –

本文发布于:2023-05-05 17:43:38,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/533696.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:添加   导致   回调   打开   请求   设置   内容
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图