从本地html文件打开本地pdf文件 [英] Open local pdf file from a local html file

查看:505
本文介绍了从本地html文件打开本地pdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个简单的html应用程序中工作,这个应用程序有望在IE8及更高版本的Chrome浏览器中运行。 html应用程序从桌面快捷方式启动,它将在默认浏览器中打开,如下所示: b
$ b

注意:html文件的路径是本地路径。



为了避免加载脚本相关的安全问题,我在我的应用程序中添加了网络标记,并且效果很好。

 <!DOCTYPE html> 
<! - 从url =(0016)保存http:// localhost - >
< html lang =en>
< head>

我现在面临的问题是,打开一个帮助文件(.pdf)位置为html文件会抛出访问被拒绝错误。



选项我曾尝试过:

a。在HTML选项卡中引用帮助文件路径并且它不起作用

 < a href =help.pdfclass = help pull-righttarget =_ blank>帮助< / a> 

a。点击上面的链接,设置window.location,如下所示,

  window.location ='help.pdf'//访问被拒绝的错误

我还提到了几个在stackoverflow中的答案,例如:
如何能我在本地运行的网页上创建了一个本地文件的链接?
但是它们都不适合我。



期望:



从本地html文件中的链接打开本地pdf文件。可能吗?让我知道你的建议。谢谢。

解决方案

试试这个,只需将ur pdf文件的位置更改为以下href ...,单独的文件夹,即你想要下载的html和pdf文件。



< html>< body>< script src =http: < script>< ('a#someID')。attr({target:'_blank',href:'http://math.hws.edu/eck/cs124/downloads/javanotes6-linked.pdf'}); //给出文件的位置...在href< / script>< / body>< / html>


I am working in a simple html application which is expected to run in IE8 and above, Chrome browsers. The html application is launched from a desktop shortcut and it will open in the default browser as shown below,

Note: The path of the html file is local path.

To avoid security issues related in loading scripts, I have added the "Mark of the Web" in my application and it works great.

<!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.

Options I have tried:

a. Referred the help file path in the HTML tab and it did not work

<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 = '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? but none of them worked for me.

Expectation:

Open a local pdf file from a link in local html file. 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.

<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>

这篇关于从本地html文件打开本地pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆