0

Is this possible :

A web page (index.html) is run locally . It checks is a directory in the root of the web folder exists .

Eg Root has an index.html and a folder called test.

The webpage would check for test to exist. If it does then a div called test-info will be shown on the index page. If it dosent then another dive called error is shown.

Is this possible with JavaScript?

Tom
  • 27
  • 6
  • Read this (reading local files with JavaScript) - http://www.html5rocks.com/en/tutorials/file/dndfiles/ – ggdx Nov 10 '14 at 16:44

2 Answers2

0

Javascript itself does not have any I/O capabilities, however what you could do is use a php script and an ajax call to do this.

muuk
  • 932
  • 1
  • 7
  • 15
0

You may be able to make HTTP requests from JavaScript to the server to test whether those resources exist. This depends upon whether the server is configured to return anything for the URIs in question. In the best case, you could make a HEAD request and check if the response code is 200 (ok) or 404 (not found), and go from there.

Community
  • 1
  • 1
Drew Noakes
  • 300,895
  • 165
  • 679
  • 742