SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2010
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile I want to use var to get folder name by javascript?

    I want to use var to get folder name by javascript?
    Can everyone help me???
    I writed like:
    http://muangay123.com/hoi_sitepoint/can_hoi.zip

    code file.htm:
    <script>
    thu_muc=new Array();
    thu_muc[0]="may_danh_giay";
    thu_muc[1]="may_loc_khong_khi";
    i=Math.floor(Math.random()*thu_muc.length);
    a=thu_muc[i];
    </script>

    <script src="a/tieude.js"></script>
    <script>
    document.write(tieude);
    </script>
    Example: http://muangay123.com/hoi_sitepoint/can_hoi.zip

  2. #2
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    If you want to include a JS file from a specific folder, you'll probably want to use JavaScript to inject the reference to it in the header:

    Code JavaScript:
    var theHtmlHead = document.getElementsByTagName("head")[0]; //get reference to the <head> tag
    var newScript = document.createElement('script'); //create a new DOM script element in memory
    newScript.type = 'text/javascript'; //set the type
    newScript.src = '/'+someFolder+'/your-script.js'; //and the source (this is where you could change the folder/file name)
    theHtmlHead.appendChild(newScript); //add our new script element to the <head>
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }


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
  •