tags:

views:

691

answers:

3

I want to list the names of HTML files in a particular folder using JavaScript (in the browser)... Can anybody help me in this? Thank You

+3  A: 

If you're using Javascript that's running in the browser, there's no way to "open a folder". You have to obtain data about the folder contents through some data structure or by doing something like parsing a server generated folder index in HTML.

If you're using Javascript that's running on a non-browser engine (such as jscript, rhino, etc.) then you have to be more specific in the question as the answer will obviously depend on whether the engine where your script is running provides objects to access the filesystem or not.

Miguel Ventura
thank u so much for answering....I am running javascript in a browser....so can tell me how i can obtain a folder data in data structure?
Prajakta B.
Perhaps you mean "using a Java script"?
Kinopiko
There's no such thing as a "java script".
Pointy
@Pointy: Oh really? I'm sorry!
Kinopiko
Yeah, it's a bit like saying a C or a .Net. Javascript is the name of the language - a Java script would be a script written in Java - but Javascript != Java.
Rich Bradshaw
@Rich: Originally the question stated "using a javascript", so I was just making a joke. I then edited the question so the joke is lost. I left the comment above since Pointy had responded.
Kinopiko
+1  A: 

Javascript can't interact with the OS while running inside a browser, due to security concerns.

It can get a list from the server and display that to the client on the browser, but, to get a directory structure from the client computer to the browser would require some other application reading the directory structure and sending it to the server, and the server sending it to the browser.

Now, if you are using Actionscript it is possible to read the hard drive, and I expect that Silverlight would allow you to do this also, but I don't know.

James Black
A: 

This is what you are asking for:

http://www.irt.org/articles/js014/index.htm

Also read on FSO

But yes, if you can't use FSO if ActiveX is disabled on client system.

Rakesh Juyal
thanks a lot..............
Prajakta B.