Solved

webpage code help needed

Posted on 2013-05-23
3
317 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 250 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 250 total points
ID: 39191630
Or use a "head" request
0
 
LVL 57

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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Power Action 2 38
HTML CSS and  Table design 4 55
isNaN issue on the Table input text 2 37
How does GeoJson relates to Leaflet and Mapbox? 4 42
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

731 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