简体   繁体   English

从本地html文件打开本地pdf文件

[英]Open local pdf file from a local html file

I am working in a simple html application which is expected to run in IE8 and above, Chrome browsers. 我正在使用一个有望在IE8及更高版本的Chrome浏览器中运行的简单html应用程序。 The html application is launched from a desktop shortcut and it will open in the default browser as shown below, html应用程序是通过桌面快捷方式启动的,它将在默认浏览器中打开,如下所示,

在此处输入图片说明

Note: The path of the html file is local path. 注意:html文件的路径是本地路径。

To avoid security issues related in loading scripts, I have added the "Mark of the Web" in my application and it works great. 为了避免与加载脚本有关的安全问题,我在应用程序中添加了“ Web标记”,它的效果很好。

<!DOCTYPE html>
<!-- saved from url=(0016)http://localhost -->
<html lang="en">
<head>

The issue I am facing now is, opening a help file (.pdf) which is in the same location as html file throws "Access Denied" error. 我现在面临的问题是,打开一个与html文件位于同一位置的帮助文件(.pdf)会引发“访问被拒绝”错误。

Options I have tried: 我尝试过的选项:

a. 一种。 Referred the help file path in the HTML tab and it did not work 在HTML标签中引用了帮助文件路径,但该路径无效

<a href="help.pdf" class="help pull-right" target="_blank">Help</a>

a. 一种。 On the above link click , set the window.location as shown below, 在上面的链接上,单击,如下所示设置window.location,

window.location = 'help.pdf' //access denied error

I have also referred several answers in stackoverflow say for example: How can I create a link to a local file on a locally-run web page? 我还提到了stackoverflow中的几个答案,例如: 如何在本地运行的网页上创建指向本地文件的链接? but none of them worked for me. 但他们都没有为我工作。

Expectation: 期望:

Open a local pdf file from a link in local html file. 通过本地html文件中的链接打开本地pdf文件。 Is it possible? 可能吗? Let me know your suggestions. 让我知道您的建议。 Thanks. 谢谢。

try this out, just change location of ur pdf file into below href ..., better put thm in a seperate folder ie the html and pdf file that u wanna download. 试试看,只需将ur pdf文件的位置更改为href ...以下,最好将它们放在单独的文件夹中,即您要下载的html和pdf文件。

 <html> <body> <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script> <a href="#" id="someID" >continue</a> <script> $('a#someID').attr({target: '_blank', href : 'http://math.hws.edu/eck/cs124/downloads/javanotes6-linked.pdf'}); // give the location of ur file... in href </script> </body> </html> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM