...

View Full Version : What if URL Variable Doesn't exist ?



fuseboxx
08-29-2005, 07:42 PM
Hi - I have a simple script that I use to open a file in a frameset based on the variable passed in the URL. What it does is take the URL= variable and set that as the main frameset. The only problem is if the page doesn't exist I get a 404 error.

I'd like to enhance it a bit more and if the file doesn't exist I would also like to set the URL Variable to my main.htm page.


I know in JavaScript you check for the existence of the file, but I'm not sure what the.asp code is to validate this ---- Would appreciate any guidance - the script is below

********************************************************







<%@LANGUAGE="VBSCRIPT"%>

<% If Request.QueryString("URL") = "" Then URL = "welcome.htm" Else URL = Request.QueryString("URL") End If %>

<html>
<head>
<title></title>
</head>
<frameset framespacing="0" border="false" frameborder="0" rows="85,*">
<frame name="top" scrolling="no" src="top.htm" marginwidth="0" marginheight="0" target="main">
<frame name="main" src="<%= URL %>">

<noframes>
<body>
text Here
</body>
</noframes>
</frameset>
</html>

nikkiH
08-29-2005, 08:48 PM
You'd have to use the Scripting.FileSystemObject object and the FileExists (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/jsmthfileexists.asp)function.

rrhodes
08-30-2005, 04:19 PM
If you have access to IIS on your web server, you can set the default 404 file not found action to go to your home page instead of the standard 404 error page.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum