使用javascript在iframe中打开本地pdf文件

时间:2015-08-20 16:33:02

标签: javascript iframe

我使用以下代码打开pdf文件,但它无效 -

D:\Temp\test>sbt -v update
Getting org.scala-sbt sbt 0.13.9 ...

:: problems summary ::
:::: WARNINGS
        problem while downloading module descriptor: http://nexusserver:8081/nexus/content/groups/mvn-repositories/org/scala-lang/scala-library/2.10.5/scala-library-2.10.5.pom: invalid sha1: expected=c39e31e37ce77d8d5fb8e8c640222275815d36f2 computed=4e8b721680f2defb491fe90447302658d464d5c
0 (351ms)

                module not found: org.scala-lang#scala-library;2.10.5

        ==== local: tried

          C:\Users\ak\.ivy2\local\org.scala-lang\scala-library\2.10.5\ivys\ivy.xml

          -- artifact org.scala-lang#scala-library;2.10.5!scala-library.jar:

          C:\Users\ak\.ivy2\local\org.scala-lang\scala-library\2.10.5\jars\scala-library.jar

        ==== my-ivy-proxy-releases: tried

          http://nexusserver:8081/nexus/content/groups/ivy-releases/org.scala-lang/scala-library/2.10.5/ivys/ivy.xml

        ==== my-maven-proxy-releases: tried

          http://nexusserver:8081/nexus/content/groups/mvn-repositories/org/scala-lang/scala-library/2.10.5/scala-library-2.10.5.pom

        problem while downloading module descriptor: http://nexusserver:8081/nexus/content/groups/mvn-repositories/org/scala-lang/scala-compiler/2.10.5/scala-compiler-2.10.5.pom: invalid sha1: expected=9a85822af1f9ea46b49dfdfa99eafc0bd819abaf computed=c3e0b6cf2f45a5a7cb052ef9e00f8fdac55e7
1b7 (69ms)

                module not found: org.scala-lang#scala-compiler;2.10.5

        ==== local: tried

          C:\Users\ak\.ivy2\local\org.scala-lang\scala-compiler\2.10.5\ivys\ivy.xml

          -- artifact org.scala-lang#scala-compiler;2.10.5!scala-compiler.jar:

          C:\Users\ak\.ivy2\local\org.scala-lang\scala-compiler\2.10.5\jars\scala-compiler.jar

        ==== my-ivy-proxy-releases: tried

          http://nexusserver:8081/nexus/content/groups/ivy-releases/org.scala-lang/scala-compiler/2.10.5/ivys/ivy.xml

        ==== my-maven-proxy-releases: tried

          http://nexusserver:8081/nexus/content/groups/mvn-repositories/org/scala-lang/scala-compiler/2.10.5/scala-compiler-2.10.5.pom

        problem while downloading module descriptor: http://nexusserver:8081/nexus/content/groups/mvn-repositories/org/scala-lang/scala-reflect/2.10.5/scala-reflect-2.10.5.pom: invalid sha1: expected=3a6fa11041ac0c8b4d5fcf9d4f1372ba8c0b7216 computed=30f1f646114a79eeefb254ead190f045c460564
9 (67ms)

                module not found: org.scala-lang#scala-reflect;2.10.5

        ==== local: tried

          C:\Users\ak\.ivy2\local\org.scala-lang\scala-reflect\2.10.5\ivys\ivy.xml

          -- artifact org.scala-lang#scala-reflect;2.10.5!scala-reflect.jar:

          C:\Users\ak\.ivy2\local\org.scala-lang\scala-reflect\2.10.5\jars\scala-reflect.jar

        ==== my-ivy-proxy-releases: tried

          http://nexusserver:8081/nexus/content/groups/ivy-releases/org.scala-lang/scala-reflect/2.10.5/ivys/ivy.xml

        ==== my-maven-proxy-releases: tried

          http://nexusserver:8081/nexus/content/groups/mvn-repositories/org/scala-lang/scala-reflect/2.10.5/scala-reflect-2.10.5.pom

                ::::::::::::::::::::::::::::::::::::::::::::::

                ::          UNRESOLVED DEPENDENCIES         ::

                ::::::::::::::::::::::::::::::::::::::::::::::

                :: org.scala-lang#scala-library;2.10.5: not found

                :: org.scala-lang#scala-compiler;2.10.5: not found

                :: org.scala-lang#scala-reflect;2.10.5: not found

                ::::::::::::::::::::::::::::::::::::::::::::::



:: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
unresolved dependency: org.scala-lang#scala-library;2.10.5: not found
unresolved dependency: org.scala-lang#scala-compiler;2.10.5: not found
unresolved dependency: org.scala-lang#scala-reflect;2.10.5: not found
Error during sbt execution: Error retrieving required libraries
  (see C:\Users\ak\.sbt\boot\update.log for complete log)
Error: Could not retrieve sbt 0.13.9

对于谷歌文档,以下代码工作正常,我不确定打开本地保存的文档需要什么。

<iframe src="file:///C:\Users\Downloads\0895custbill08132015.pdf" style="height: 638px;" frameborder="0"></iframe>

3 个答案:

答案 0 :(得分:0)

您在src中使用了反斜杠。请将它们改为斜杠

<iframe src="file:///C:/Users/Downloads/0895custbill08132015.pdf" style="height: 638px;" frameborder="0"></iframe>

答案 1 :(得分:0)

出于安全原因,大多数浏览器都不允许您从网站打开本地存储的文件。通常情况下,我会将文件托管在IIS服务器上,然后从那里检索(当你从googledoc中检索它时,这就是你正在做的事情。)

答案 2 :(得分:0)

你可以使用     var pdf = $(&#39; \&lt; \ object type =&#34; application / pdf&#34;&gt;&#39;);     pdf.attr(&#39;数据&#39;,&#34;你是pdf scr&#34;); 将其添加到您的iframe中。