• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 200
  • Last Modified:

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

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
wymerc
Asked:
wymerc
1 Solution
 
radnorCommented:
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now