Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

webpage code help needed

Posted on 2013-05-23
3
Medium Priority
?
321 Views
Last Modified: 2013-06-09
I have this code that adds a textbox and submit button on my webpage, it takes whatever you enter into the textbox and goes to a address in this case http://jy*******/yur*****/intranet/ adds your text (let's say AML1) and adds .pdf to the end.

Here is what it would look like in case you didn't follow me

http://jy*******/yur*****/intranet/AML1.pdf

My problem is that if the file dosen't exist on the server you get the standard 404 error, now I know that I could change the 404 error and make it custom however I wanted to know if there was a way to check if that file exists and if not redirect them to a different page.

Here is the code:

<html lang="en">
<head>
<base target="main">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="language" content="english">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">

<title></title>

<style type="text/css">
#wrapper {
    width:482px;
    margin:auto;
 }
.container {
    float:left;
    width:195px;
    border:0px double #;
    padding:10px 10px 0;
    font-family:sans-serif;
    color:#3333cc;
    text-align:center;
    background-color:#cf8030;
    margin:0 10px;
 }
.container h1 {
    margin:0 0 10px 0;
    font-size:1em;
 }
.container input {
    margin-bottom:10px;
 }
</style>

<script type="text/javascript">

function init() {

   var kywd=['','KEYWORD/'];
   var df=[];
   f=document.getElementsByTagName('form');
for(c=0;c<f.length;c++) {
   df[c]=document.forms[c];
   df[c].number=c;
   df[c].onsubmit=function() {  
   location.href='http://jy*********/yur*****/intranet/'+kywd[this.number]+df[this.number][0].value+".pdf";
   return false;
   }
  }
 }
   window.addEventListener?
   window.addEventListener('load',init,false):
   window.attachEvent('onload',init);

</script>

</head>
<body>

<div id="wrapper">

<form action="#">
<div class="container">
<h1>Enter Password</h1>
<input type="password">
<input type="submit" value="Submit"/>
</div>
</form>


</div>

</body>
</html>
0
Comment
Question by:KevinSchildt
[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
3 Comments
 
LVL 13

Accepted Solution

by:
AielloJ earned 750 total points
ID: 39191529
KevinSchildt,

That type of error can be caught in several ways.  What type of scripting resources you have will determine how you approach it.

1) You could use AJAX and the XMLHttpRequest.status function to test if the page exists.  This is pretty much a JavaScript only solution.  No scripting language needed.
2) You could use your scripting language (php, etc) to handle this on the server.  This allows more sophisticated handling of things.

Best regards,

AielloJ
0
 
LVL 75

Assisted Solution

by:Michel Plungjan
Michel Plungjan earned 750 total points
ID: 39191630
Or use a "head" request
0
 
LVL 59

Expert Comment

by:Julian Hansen
ID: 39191723
You can also catch this in the .htaccess file - and redirect it to another location if it does not exist.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

618 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