javascript PDF.js 不适用于 Internet Explorer

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23312057/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 00:42:37  来源:igfitidea点击:

Pdf.js not working on Internet Explorer

javascripthtmlinternet-explorer

提问by maxus182

Can anyone explain me why this code don't work in IE? In Chrome everything works just fine.

谁能解释一下为什么这段代码在 IE 中不起作用?在 Chrome 中一切正常。

Part of my Html:

我的 HTML 的一部分:

<head>
<script type='text/javascript' src="//code.jquery.com/jquery-1.9.1.js"></script>
<script type='text/javascript' src="http://vivin.net/pub/pdfjs/pdf.js"></script>
<script type='text/javascript' src="http://vivin.net/pub/pdfjs/textlayerbuilder.js"</script>
</head>  
<body>
<div id="pdfContainer" class = "pdf-content"></div>
</body>

Full code and example that works on Chrome: http://jsfiddle.net/vivin/RjqUf/

适用于 Chrome 的完整代码和示例:http: //jsfiddle.net/vivin/RjqUf/

采纳答案by maxus182

I've figured out what my problem was. I replaced the pdf.js with pdf.min.js and now everything works fine in both Explorer 10 and Chrome. Don't know exactly why, but it works.

我已经弄清楚我的问题是什么了。我用 pdf.min.js 替换了 pdf.js,现在在 Explorer 10 和 Chrome 中一切正常。不知道确切原因,但它有效。

回答by nolawi

the reason it doesnt work is because pdf.js is not supported by ie9 and below https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#what-browsers-are-supported

它不起作用的原因是 ie9 及以下不支持 pdf.js https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#what-browsers-are-supported

if you want to force users to embed pdf in ie7,8,9 you can do this

如果你想强制用户在 ie7,8,9 中嵌入 pdf 你可以这样做

<embed src="../pdfFileName.pdf" class = "pdf-content">
.pdf-content {your style and size}

this works if they have somekind of pdf reader

如果他们有某种 pdf 阅读器,这会起作用

if you want fallback you can use <object>tag there is a discussion EMBED vs. OBJECTabout embeding vs object

如果你想回退,您可以使用<object>标签有一个讨论,嵌入与对象有关embeding VS对象