IE、Chrome等浏览器实现PDF预览(原)

IE、Chrome等浏览器实现PDF预览
<!doctype html>
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=gb2312">
        <meta http-equiv="content-style-type" content="text/css">
        <meta http-equiv="content-script-type" content="text/javascript">
        <title>Checking If PDF Can Preview...</title>
        <script type="text/javascript">
            function checkPDF(){
                /*if(!!(document.getElementById('PDFNotKnown'))){
                    document.getElementById('IfNoPDFAXExist').style.display = "block";
                }
                else{
                    document.getElementById('IfPDFAXExist').style.display = "block";
                }*/
                document.getElementById('PDFViewObject').style.display = "block";

            }           
        </script>
    </head>
    <body onload="checkPDF()">
        <noscript>
            cannot determine if you have acrobat reader (or the full acrobat)
            installed <font size="-1">(because javascript is unavailable or
            turned off)</font>.
        </noscript>
        <!--<div id="IfNoPDFAXExist" style="display:none">
            你需要先安装pdf阅读器才能正常浏览文件,请点击<a href="http://get.adobe.com/cn/reader/download/?installer=reader_11.0_chinese_simplified_for_windows" target="_blank">这里</a>下载.
        </div>-->

        <object id="PDFViewObject" type="application/pdf" width='100%' height='100%' data='mxl.pdf' style="display:none">
            <!--这里面的div只有浏览器不支持application/pdf时才会被显示-->
            <!--IE8以及以下版本的IE在浏览器不支持application/pdf时不会加载下面的div从而可以通过上面的checkPDF来处理,
            IE9以及以后的版本以及Chrome都会加载,所以无效-->

            <div id="PDFNotKnown">你需要先安装pdf阅读器才能正常浏览文件,请点击<a href="http://get.adobe.com/cn/reader/download/?installer=reader_11.0_chinese_simplified_for_windows" target="_blank">这里</a>下载.</div>
        </object>
        <!--<embed id="IfPDFAXExist" style="display:none" width="100%" height="100%" name="plugin" src="mxl.pdf" type="application/pdf">-->
    </body>
</html>




原文地址:https://www.cnblogs.com/boulder/p/c2f99c56d8462ecd460c1e3aef3b307a.html