Solved

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

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
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)

777 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