• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
在北京的四川小伙
一切不以结婚为目的的恋爱,都是耍流氓 -----爱因斯坦●涛
博客园    首页    新随笔    联系   管理    订阅  订阅

pdf.js打开PDF可跨域

 1 <html>
 2 <head>
 3     <meta charset="UTF-8">
 4     <title>Document</title>
 5     <style type="text/css">
 6         .lightbox{
 7             position: fixed;
 8             top: 0px;
 9             left: 0px;
10             height: 100%;
11             width: 100%;
12             z-index: 7;
13             opacity: 0.3;
14             display: block;
15             background-color: rgb(0, 0, 0);
16             display: none;
17         }
18         .pop,iframe{
19             position: absolute;
20             left: 50%;
21             top:0;
22             width: 893px;
23             height: 100%;
24             margin-left: -446.5px;
25             z-index: 9;
26         }
27     </style>
28     <script src="js/pdf.js" type="text/javascript"></script>
29     <script type="text/javascript">
30         function showPdf(isShow) {
31             var state = "";
32             if (isShow) {
33                 state = "block";
34             } else {
35                 state = "none";
36             }
37             var pop = document.getElementById("pop");
38             pop.style.display = state;
39             var lightbox = document.getElementById("lightbox");
40             lightbox.style.display = state;
41         }
42         function close() {
43             showPdf(false);
44         }
45     </script>
46 </head>
47 <body>
48     <ul>
49         <li><a href="http://h5.xxx.com/1/333.pdf" target="pdfContainer" onclick="showPdf(true)">0001_pdf</a></li>   
50     </ul>
51     <div class="lightbox" id="lightbox"></div>
52     <div id="pop" class="pop" style="display: none;">
53         <a href="javascript:close()" style="
54             position: absolute;
55             right: -90px;
56             display: inline-block;
57             width: 80px;
58             height: 30px;
59         " id="close">关闭</a>
60         <iframe src="" frameborder="0" id="pdfContainer" name="pdfContainer"></iframe>
61     </div>
62 </body>
63 </html>

 Js下载

如今的编程是一场程序员和上帝的竞赛,程序员要开发出更大更好、傻瓜都会用到软件。而上帝在努力创造出更大更傻的傻瓜。目前为止,上帝是赢的。 QQ:6203142 -----在北京的四川小伙
posted @ 2017-07-12 16:20  在北京的四川小伙  阅读(3216)  评论(1)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3