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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking that a folder exists

Status
Not open for further replies.

Coogan

Programmer
Jun 21, 2004
38
GB
Can anyone help me with this 'If then else' statement.

I want to check that a folder exists and if it does then it opens that folder in a new window and if it doesn't exist then I want it to open an error page in the current window.

Code:
if (this.form.url.value exists) then window.open( this.form.url.value) else document.location = 'error.htm';

I am trying to figure out the (this.form.url.value exists) code. Can anyone help??
 

If by "folder", you mean a physical directory on a disk, then you'll have a job... Assuming this code is client-side, and not server-side, you'll only be able to do this in IE, by using the ActiveX "FileSystemObject" control.

Hope this helps,
Dan
 
I want it to look for a web folder on my site.

Thinking about it I could get it to check if a page exists so it would be more like.

Code:
pageaddress = this.form.url.value exists + "index.htm"
if ( pageaddress exists ) then window.open( pageaddress ) else document.location = 'error.htm';
 

>> I want it to look for a web folder on my site.

Then you will have to use server-side scripting. Do you have this available to you (ASP, JSP, PHP, etc)?

Dan
 
Dan

Yeah I do have these available to me but I have no idea where to start with any of those.
 

>> Yeah I do have these available to me but I have no idea where to start with any of those.

I suggest you pick the one you want to work with, and post a message in the relevant forum.

Hope this helps,
Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top