0

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,

enter image description here

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.

Community
  • 1
  • 1
JGV
  • 5,037
  • 9
  • 50
  • 94

1 Answers1

0

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>
Kathiresan. N
  • 48
  • 1
  • 12
  • I cannot put the pdf in a separate location. The computers where I am deploying the html application does not have any internet connection. The .pdf file should remain in the same location as html file. – JGV Feb 25 '16 at 19:26
  • yeah, create any folder in desktop or in any drive , then keep ur pdf file and html, once it is done , i have given my own location ie an http location, u try to change it as ur file name alone like this 'code' $('a#someID').attr({target: '_blank', href : ' filename.pdf ' }); – Kathiresan. N Feb 26 '16 at 03:53
  • I tried the same using javascript (as I don't use jquery in this project) and it throws Access Denied error in browser. – JGV Feb 26 '16 at 16:54
  • Download this pdf – Kathiresan. N Feb 26 '16 at 20:19