Solved

Redirecting to another page when a 404 error occurs or file not found

Posted on 2007-03-26
1
188 Views
Last Modified: 2012-05-05
I am building a string in a web page based on criteria outlined in drop down controls.  This sting will correspond with the name of a file that will be uploaded to a web folder through another process.  If the process does not find the file it currently gives a 404 error.  I would like to write an if statement in the code that if the file isn't there, then display another page.  The current function to find the file is below.

<script language="javascript">
function showFileName()
{
  window.location= "http://domain/documents/ProgressReports/" +yr.value + mth.value + day.value + typ.value + ".txt" ;
}
</script>
0
Comment
Question by:wymerc
1 Comment
 
LVL 8

Accepted Solution

by:
radnor earned 125 total points
Comment Utility
With JS, you cannot test for a file.  If you want something other than the standard 404 error, look into .htaccess file.  Here you can display a page instead of the normal 404 error.

http://www.javascriptkit.com/howto/htaccess2.shtml
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now