Click to See Complete Forum and Search --> : HTML file
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.
ua549
05-16-2003, 01:25 PM
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.
<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:/
Pinky
05-17-2003, 11:06 AM
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. :)
EverlastingGod
05-18-2003, 03:20 AM
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.
<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>
:mad: JavaScript isn't Java!!!
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.
ua549
05-18-2003, 01:46 PM
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.
EverlastingGod
05-19-2003, 09:36 AM
If you can't get it to run make sure:
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>");
is all on one line...
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!