如何锚定<a href=""> be created without the protocol and domain?

时间:2018-12-02 17:09:08

标签: html selectpdf

What is the correct way to do this and have what is generated / used by the browser be relative paths?

I need to do this in order to generate PDF's with links that will open files in a folder directory on a user's hard drive. The links must use relative paths, since the files will be downloaded in a directory structure that will be moved around on the hard drive. To further clarify the use case, the PDF(s) and the files will be downloaded in zip archives together, so the initial relative location will always be known.

I understand there are things in place in browsers to prevent this working from within a browser window, but in this case it will only be used in anchors in PDF files generated from HTML.

One of the problems with using something like this is that the protocol and domain is appended to the front of the path in the anchor. The relative path that's needed is to navigate within a folder directory in Windows Expolorer.

<a href="../Project_Archive/Files/file.txt">file.txt</a>

The PDF's are converted from HTML using SelectPdf, and this is an Asp.Net MVC web app.

I have tried variations of this, which windows explorer is not able to use:

<a href="file:///../Project_Archive/Files/file.txt">file.txt</a>

0 个答案:

没有答案