SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    loader for *.js files ??

    hi ..

    is there any code to load all *.js file from folder?

    coz i would like to protect my js files, so if i load them all by *.js from folder and folder mode is 711, no 1 can view or get the files .

  2. #2
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can probably do this using wsh, but my opinion would be to use php

    PHP Code:
    <?

    echo "<ul>";

    function 
    GetDirArray($sPath) {

    echo(
    "<a href=\"$sPath\"><font color=\"#000000\">Getting $sPath</font></a>\n");

        if (
    $handle opendir($sPath)) {
            while (
    false !== ($file readdir($handle))) { 
                if (
    $file != "." && $file != "..") { 
                    
                    if ( 
    is_dir($sPath $file) ) {
                        
    GetDirArray($sPath $file '/');
                    } else {
                        echo(
    "<script type='" $sPath$file "'></script>");
                    }               
                } 
                }
                
    closedir($handle); 
        }

    }

    GetDirArray("w/");

    //MAKE SURE to include the trailing slash on the first call to the function

    ?>
    of

    you could do this

    PHP Code:

    <script type="text/javascript">

    var 
    js_files = new Array();

    js_files[0] = "javascript_0.js";
    js_files[1] = "javascript_1.js";
    js_files[2] = "javascript_2.js";
    js_files[3] = "javascript_3.js";
    js_files[4] = "javascript_4.js";
    js_files[5] = "javascript_5.js";

    for (
    a=0;a<=js_files.length;a++)
    {
    document.write ('<script type="javascript" src="' jsfiles[a] + '></' 'script>')
    }

    </script> 

  3. #3
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thx ..
    but not this way what i want!

    once i saw nice js script when i tryed to get it, i got js file which load js file from folder by *.js, and when want to get the files from this folder i couldnet access it .

    so i couldnet get the js file, and i don`t know where i stored this js file which i downloaded from that site

    it was something like this code :
    PHP Code:
    document.write("<SCR" "IPT LANGUAGE='JavaScript1.2' SRC='*.js' TYPE='text/javascript'><\/SCR" "IPT>"); 

  4. #4
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you look at my code thats exactly what mine does but you have to name the javascript files or you have to number them, say you have 10 js files

    it would look like this

    js1.js
    js2.js
    js3.js
    js4.js
    js5.js
    js6.js
    js7.js
    js8.js
    js9.js
    js10.js
    [PHP]

    <script type="text/javascript">

    var max=10;

    for (a=0;a<=max;a++)
    {
    document.write ('<script type="javascript" src="js' + max + '.js"></' + 'script>');
    }

    </script>


Bookmarks

Posting Permissions

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