0

In my HTML code I have a link to PDF file named: instructions_A.pdf

The letter 'A' will alternate every now and then.

I was wondering if I could link to the file as long as the filename contains 'instructions_'. And if I could 'retrieve' the rest of the filename.

Is there something possible like:

HTML

<div id="divid"></div>

JS

var linktext = 'instructions_'
var link = '<a id="linkID" href="instructions_?.pdf" target="_blank">' + linktext + '</a>';
document.getElementById("divid").innerHTML = link;

And than checking if the href contains 'instructions_' if so: open that file and ignore the ?.

https://jsfiddle.net/fkszw2Lc/

meekz89
  • 78
  • 9
  • 1
    Yes, you can. You will need to use a server-side language or a directory page to make sure the file name (that starts with instructions_) exists on a server, then update your link. [Here's a starting point](https://stackoverflow.com/questions/6994212/is-there-a-way-to-return-a-list-of-all-the-image-file-names-from-a-folder-using). – JM-AGMS Oct 06 '21 at 16:32

0 Answers0