Solved

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

Posted on 2007-03-26
1
196 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 125 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
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.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

734 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