I'm embedding PDF files to a very simple HTML page and everything works fine, but I need a fallback in case the source file does not exist. If the src file is not found an alternative file should be displayed (not-found.pdf for instance).
The problem is very similar as the one on the topic below but with PDF files.
Inputting a default image in case the src attribute of an html <img> is not valid?
I've tried the solutions provided on that topic but none of them worked.
I'm using a simple embed tag:
<embed src="../files/ID 41279.pdf" width="1026px" height="1780" onerror="if (this.src != '../files/not-found.pdf') this.src = '../files/not-found.pdf';">
As you can see I tried to use javascript (as suggested on the topic above) but nothing happens. On the console the error 404 (for the original file) show as usual but the document is blank.
Is it possible to do that with PDF files? It only need to work on Chrome, so compatibility with other browsers is not necessary.
A pure HTML solution would be better but using javascript or jquery is ok too.
Also, the fallback doesn't need to be a PDF file, I can make do with an image or event text (as long as I can format it).
Thanks!