0

I've got a PDF, which is filed on one of our server. I've got an url for opening this PDF in my browser like this: file://myServer/myFolder/myFile.pdf.

Now when I copy this url and paste it in a new tab in my browser (IE and Chrome), it opens it correctly.

Now I would like to implement <a></a> link tag and open the same url, which I put in the href attribut.

ex. <a target="_blank" href="file://myServer/myFolder/myFile.pdf">PDF</a>

When I click on the link, it opens the PDF again correct in a new tab in both browser (IE and Chrome).

So my next step is it, to get a json object with the url for the PDF's filed on this server. And with angularJS I'd put the url dynamicly in my link tag in the html. So I do this:

let fileObj = [
    {
        filename: 'File 1',
        url: 'file://myServer/folder1/myFile1.pdf'
    },
    {
        filename: 'File 2',
        url: 'file://myServer/folder2/myFile2.pdf'
    },
    {
        filename: 'Website XY',
        url: 'http://www.myWebsite.com'
    }
];

And than with angularJS I build a link tag in my html with the dynamic href url:

<a ng-repeat="file in fileObj" target="_blank" href="{{file.url}}">{{file.filename}}</a>

So when I look at this in my console, it has the correct url in the href and also the correct text within the a-tag etc. like in my first example above, when I wrote the url hardcoded in the href. But when I now click on the link, nothing happens on Chrome on IE it works fine! EDIT: The third link, which opens a website works on both browser... What's wrong? For me it seems to be the same like the hardcoded one, but the first one works, the second one doesn't. It's also confusing, that it works fine on IE and on Chrome not! I got follow msg in the console on chrome: Not allowed to load local resource It seems to be a browser problem...Any ideas?

Thanks.

webta.st.ic
  • 4,781
  • 6
  • 48
  • 98
  • Please look at my edit... – webta.st.ic Aug 29 '16 at 09:24
  • 1
    Relevant part of the answer on the duplicate question: "Some browsers, like modern versions of Chrome, will even refuse to cross from the http protocol to the file protocol, so you'd better make sure you open this locally using the file protocol if you want to do this stuff at all." – Quentin Aug 29 '16 at 09:29
  • Not allowed to load local resource: `file://myserver/folder1/myFile1.pdf` – Debug Diva Aug 29 '16 at 09:31
  • @Quentin Hi and thanks for your input.. I changed it on the database and now it has three slashes... But it still doesn't work, when I put the url dynamicly into the href... My web-application is local on my client and the pdf is on another server (so pdf is not located on client like the web app). Is this perhaps a problem? But why does it work hardcoded? – webta.st.ic Aug 29 '16 at 09:36
  • @Quentin It isn't a duplicate... It works fine on IE, just on Chrome it doesn't open the PDF (look at my edits). And also when I use the three slashes, it also doesn't work on IE, with two it works... So it seems to be a browser problem.. Any ideas – webta.st.ic Aug 29 '16 at 11:04
  • @MrBuggy — Did you read my original comment? Chrome won't let you link to `file:///` from a webpage hosted on `http://`. – Quentin Aug 29 '16 at 11:07
  • @Quentin I didn't see it sorry... Ok so there is no way to do this with chrome? I have to have the pdf local and then it would work? – webta.st.ic Aug 29 '16 at 11:09

0 Answers0