Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

better 404 document

Status
Not open for further replies.

lovewindoze

Technical User
Jan 16, 2003
36
US
I am wanting to create a better HTTP Error 404 document than the standard one on IIS.
I've already customized the verbage. But what I'd really like to do is provide an email link (spam proof of course) to me that includes a subject. And I want the subject to be the full url of the link they tried to get to. Hope this makes since.

So if they're on the home page, and click on a button that says PROJECTS and the link goes to but the directory doesn't exist or the index/default page doesn't exist -
I'd like the email link on the 404 error page to include the subject:
I'm hoping there is a way to do with with JavaScript?
If not, if I could at least get the Referring page..?
 
I'm not familiar with how 404 pages work. Is the URL of the unfound page still in the address bar? Is there any way to access it through IIS? If so, you can just link to "404.html?page=<bad page>" and retrieve the name of the page from there.

--Chessbot

"Violence is the last refuge of the incompetent." -- Asimov, Foundation
 
yep, the bad URL is still in the address bar.
But there's no direct linking to the 404 document.
It's called by the server, by default, when a page is not found.
 
Ok. Does this work?
Code:
<html>
<head>
<title>404 Error: Page not found</title>
<script type="text/javascript">
<!--

function printEmail()
{
  document.write("<a hre");
  document.write("f=\"mailt");
  document.write("o:ema");
  document.write("iladdr@si");
  document.write("te.com?sub");
  document.write("ject=");
  document.write(location.href);
  document.write("\">email the webmaster</");
  document.write("a>");
}

// -->
</script>
</head>
<body>
<h1>404 Error: Page not found</h1>
The page you requested cannot be found on this server. Please <script type="text/javascript">printEmail();</script> if this problem persists.
</body>
</html>

--Chessbot

"Violence is the last refuge of the incompetent." -- Asimov, Foundation
 
ooooh, it just might.
I'll try it tomorrow when I get back into work.
thanks.
 
that is awesome!
works like a charm and does exactly what I need it to do.
THANK YOU very much.
 
No problem. Glad it works.

--Chessbot

"Violence is the last refuge of the incompetent." -- Asimov, Foundation
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top