Hi,
I want to create an HTML file the shows a directory listing for all of the files in that folder. (The HTML file would be in that folder also)
Is this easy to do? Any suggestions would be appreciated.
Printable View
Hi,
I want to create an HTML file the shows a directory listing for all of the files in that folder. (The HTML file would be in that folder also)
Is this easy to do? Any suggestions would be appreciated.
Here is a chunk of code I pulled from somewhere on the internet for my own use.
I stripped out my own stuff. Just add your own enhancements.
I'm not a java person, so I can't help you further.
You can copy this code to a file such as dir.htm and it will run in a browser as is.
Code:<head>
<title>Folder contents</title>
</head>
<body bgcolor="white">
<table cellspacing="0" cellpadding="0" border="1">
<tr>
<td><script language="javascript">
if (navigator.appName=="Netscape" && navigator.appVersion.split(".")[0]==4)
{
document.write("");
}
else
{
document.write("<p align='left'><iframe src='file:///C:/' height=350 width=600 marginwidth=0
marginheight=0 scrolling=no frameborder=0 vspace=2></iframe></p>");
}
</script></td>
</body></html>
Thanks, UA549.
I just get a tiny square, but no directory listing;
I also don't understand where I'd be editing to customize for my directory. It looks somewhere around ///c:/
What http server software are you using? I should be fairly easy to get a dir listing to show without actually coding a page. For example, with Apache you could have a .htaccess file in the directory you want to see, with the line Options +Indexes. :)
:mad: JavaScript isn't Java!!!Quote:
Originally posted by ua549
Here is a chunk of code I pulled from somewhere on the internet for my own use.
I stripped out my own stuff. Just add your own enhancements.
I'm not a java person, so I can't help you further.
You can copy this code to a file such as dir.htm and it will run in a browser as is.
Code:<head>
<title>Folder contents</title>
</head>
<body bgcolor="white">
<table cellspacing="0" cellpadding="0" border="1">
<tr>
<td><script language="javascript">
if (navigator.appName=="Netscape" && navigator.appVersion.split(".")[0]==4)
{
document.write("");
}
else
{
document.write("<p align='left'><iframe src='file:///C:/' height=350 width=600 marginwidth=0
marginheight=0 scrolling=no frameborder=0 vspace=2></iframe></p>");
}
</script></td>
</body></html>
And this is client-side... he needs some kind of server-side processing.
I am not using an http server for this.
It would be available for domain users only.
Interesting. I put that bit of code in notepad and saved it as dir.htm. I then clicked the file name and it started IE6 and displayed the root folder directory. This is in a stand alone WinXP box with no web server installed, even the personal one that ships with XP.
If you can't get it to run make sure:
is all on one line...Code:document.write("<p align='left'><iframe src='file:///C:/' height=350 width=600 marginwidth=0
marginheight=0 scrolling=no frameborder=0 vspace=2></iframe></p>");
The posted code however, simply loads another "page" in an iframe. How that is "loaded" depends on your browser. A directory or file on the local machine (IE whatever) will load as if you opened that directory or file manually. So this may be what you want to do if you're not running a web server.
That's perfect. I had that line in two lines, so it didn't work.
Thanks, guys!