简体   繁体   中英

PDF link not working on webpage

Ok so I have a intranet webpage that I am making using HTML and I want to put a link (absolute or relative) on my page that opens a PDF. The code I use is

<a href="http://harold.local/documents/sandP.pdf" target="_blank">Privacy and Security</a>

Now what ends up happening is that I get this error:

404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

Is there anything wrong with my code or where I am placing the document?

Thank You

If you are running this on a local machine check the permissions on the PDF file that they are world readable. I have this happen a lot in my OS X web directory, some files dragged in seem to have different permissions.

I see a number of small... oddities... in your sample line, which may or may not be significant in themselves, but could cause problems if you're doing any post-processing of the line before it goes live.

  1. http://harold.local/documents/sandP.pdf is a good destination, correct? If you drop that by itself in to the address line of your browser, you can confirm that the PDF document can be found and displayed?
  2. If you're doing any further processing of that string, should you be escaping the slashes or backslashes by doubling each one?
  3. There's a stray space between your target= argument and your _blank value, again a possible risk if something later on will attempt to parse the string.
  4. There is what appears to be a stray Left Angle Bracket (or Less Than) symbol ("<") immediately in front of your Privacy and Security text, which could be misinterpreted as the start of a <p tag, probably not what you want.

I would start by verifying the destination, then adding the context around it a bit at a time until something breaks. Failing that, find a similar working example of the <a usage on your local machine, and use that as a starting point for the link to your sandP.pdf document.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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