HTML file

Sharky Forums


Results 1 to 9 of 9

Thread: HTML file

  1. #1
    Mako Shark Dude's Avatar
    Join Date
    Dec 2000
    Location
    CA
    Posts
    3,539

    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.
    <(" )> <(")> <( ")> Kirby Dance! <(" )> <(")> <( ")>
    "I liek shinny things"

  2. #2
    Great White Shark
    Join Date
    Nov 2000
    Posts
    21,595
    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>

  3. #3
    Mako Shark Dude's Avatar
    Join Date
    Dec 2000
    Location
    CA
    Posts
    3,539
    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:/
    Last edited by Dude; 05-17-2003 at 03:10 AM.
    <(" )> <(")> <( ")> Kirby Dance! <(" )> <(")> <( ")>
    "I liek shinny things"

  4. #4
    Stormtrooper Mod Pinky's Avatar
    Join Date
    Oct 2000
    Posts
    2,971
    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.

    Proofread carefully to see if you any words out.

    [the rules]

  5. #5
    Hammerhead Shark EverlastingGod's Avatar
    Join Date
    Feb 2003
    Location
    MD
    Posts
    1,364
    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>
    JavaScript isn't Java!!!

    And this is client-side... he needs some kind of server-side processing.
    Stay cool
    and be somebody's fool this year

  6. #6
    Mako Shark Dude's Avatar
    Join Date
    Dec 2000
    Location
    CA
    Posts
    3,539
    I am not using an http server for this.
    It would be available for domain users only.
    <(" )> <(")> <( ")> Kirby Dance! <(" )> <(")> <( ")>
    "I liek shinny things"

  7. #7
    Great White Shark
    Join Date
    Nov 2000
    Posts
    21,595
    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.

  8. #8
    Hammerhead Shark EverlastingGod's Avatar
    Join Date
    Feb 2003
    Location
    MD
    Posts
    1,364
    If you can't get it to run make sure:
    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>");
    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.
    Stay cool
    and be somebody's fool this year

  9. #9
    Mako Shark Dude's Avatar
    Join Date
    Dec 2000
    Location
    CA
    Posts
    3,539
    That's perfect. I had that line in two lines, so it didn't work.

    Thanks, guys!
    <(" )> <(")> <( ")> Kirby Dance! <(" )> <(")> <( ")>
    "I liek shinny things"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •