Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jan 2013
    Thanked 0 Times in 0 Posts

    Smile Pre Load Content Help


    I am would like to know how I would be able to achieve what I am after.

    In one of my parent folders I add new sub folders in each sub folder has a has a html page with content and also a folder for images for that sub folder.

    If new sub folder created in the houses folder I would like that to show up in housesforsale.html in list format showing image sample description etc. how would I achieve this?

    example : listings

    example : listings > /houses > /16 fake Street

  • #2
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Thanked 494 Times in 488 Posts
    I know of no way for a client side script to read either a server or local computer directory with JS.

    You could create an external .txt file to be read and acted upon by an AJAX load routine
    or you could create a special JS file with an extension of .js that could be read by the html as it loads.

  • Users who have thanked jmrker for this post:

    Carrara_WS (08-10-2013)

  • #3
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Thanked 569 Times in 550 Posts
    Quote Originally Posted by jmrker View Post
    I know of no way for a client side script to read either a server or local computer directory with JS.
    via server: http://cdn.atlas.illinois.edu/will.i.../node_modules/
    also webDAV, common and available with apache and IIS, if enabled, can list and even grep the folders and files for you.

    javascript uses a process called ajax to get this information from the server to the client.

    from a local computer, you can drag the folder into the browser in at least chrome, or rip up a zip file in any half-way recent browser.

    to the OP:
    you cannot make info from a sub-dir file into housesforsale.html, but you can use javascript running in housesforsale.html to fetch an updated list of folders and update the on-screen list. You can use a predictable file name to show thumbnails, but textual descriptions are another issue, as it the full text. You would have to load each sub-dir file from housesforsale.html and extract the text you need from the html file.

    That's all certainly doable, but you're getting into territory that a simple CMS or PHP framework, or dreamweaver templates, or maybe even old-fashioned SSI would be better suited to deliver. if you had a server build the list instead of the JS, you don't need to transfer over every html file to get the description, you can pluck it right into the list before shipping.

    you can also do a half-way hybrid routine that uses the slow ajax routine outlined to build a new housesforsale.html page for you, that you then ftp up to the server. this essentially uses JS as a poor-man's server/dreamweaver renderer, but only you have to wait for all the files to be scanned, not your clients. the end result of a routine like that or dreamweaver will always vastly out-perform even the aforementioned server-side routine that scans the folders each time. cheap, simple, and fast, but only semi-auto...
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/1/19) IE7:0.2, IE8:6.7, IE11:7.4, IE9:3.8, IE10:4.4, FF:18.3, CH:43.6, SF:7.8, MOBILE:27.5

  • Users who have thanked rnd me for this post:

    Carrara_WS (08-10-2013)


    Tags for this Thread

    Posting Permissions

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