0

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
  • 2
    Is the 'folder' on the client (i.e. where the browser is running) or the server (where the HTML and JS are loaded from)? Commented Oct 25, 2009 at 14:05
  • @rjstelling: Obviously if he is using Javascript, then he must be saying about client side. Commented Oct 25, 2009 at 14:22
  • 1
    @Rakesh not entirely obvious, as there does exist server side javascript - Rhino,SpiderMonkey, etc. Commented Oct 25, 2009 at 14:54

3 Answers 3

3

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.

Sign up to request clarification or add additional context in comments.

6 Comments

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?
Perhaps you mean "using a Java script"?
There's no such thing as a "java script".
@Pointy: Oh really? I'm sorry!
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.
|
0

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.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.