?
Solved

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

Posted on 2007-03-26
1
Medium Priority
?
198 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 8

Accepted Solution

by:
radnor earned 375 total points
ID: 18793747
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

Interactive Way of Training for the AWS CSA Exam

An interactive way of learning that will help you visualize core concepts so that you can be more effective when taking your AWS certification exam.  Built for students by a student to help them understand the concepts that they are being taught.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

765 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