I have the following javascript code, I redirect old link to a new one dynamically.
Sometimes newLink does not exist, and instead of getting 404 page, I want to custom my own page if URL was not found.
Any idea how to add this condition in my code please ?
<script>
setTimeout(function(){
$('a[href="oldLink"]').attr('href','dir/newLink)
}, 1000);
</script>
EDIT : I am running this code on Rstudio, I am new to javascript, I don't have a server because I am producing HTML pages using Rmarkdown locally.
Thanks !