Set a link

I have a short question. I have set a link to a pdf file. I use not the feature “download pdf” …
I only set a link, for example:
then I put the file on the server. It works. But sometimes there is for a few weeks no flyer.pdf with new sales or something. Is it possible to set the same link when the file is not found and then I get redirect on a page I have made with text…for example next flyer coming soon …
hard to explain
sorry :thinking:

Hi @tom2

It’s possible, but you will need to set up some js to check if the link exists, sim. to this:

The js:
function checkLocation (e, loc) {
type: ‘HEAD’,
url: ‘
.done (function(loc) {
// page exists
window.location = loc;
.fail (function() {
// page does not exist
window.location = “”;
The html:
<a href="" onclick="checkLocation(e, '')" >Click Here</a>

Not tested, but I think all these pieces should be right or very close anyway :wink:


1 Like

HI @Bill
thanks a lot for your help …I am soooo bad in coding :blush:
Do I need an editor to write a js file ?
Are this the steps:

  1. write the js file
  2. put the js file in the project ? ( but where ? )
  3. put the html code into the page settings ?


thanks Tom

Hi @tom2

Sorry for the delay, I don’t get email notices - bummer.

Yes, you need a simple text editor - I use BBEdit - free version

  1. Yes, copy my code into a file and name it something.js and put it w/ your other files for your site. Obviously you’ll need to edit the code to match what you need.
  2. Page > Settings & click plus button for header file attachments and browse to the file you created
  3. Put the html code in a Code Widget bric.

Have fun.