Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    May 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    getting the name of the first folder in a breadcrumb trail

    I need some code in Javascript that gets the name of the top level folder that's at the root directory of the current page.

    So for example, if I am at a page called mywebsite.com/folder1/folder2/folder3/index.hmtl ,I want to be able to get the name of folder1.

    Any ideas please?

    Cheers,

    Garry

  • #2
    New to the CF scene
    Join Date
    May 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    getting the name of the first folder a bread crumb trail

    hi,

    i'm trying to get the name of the first folder in the structure root of the current page. how do i do this?

    thannks

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Code:
    var firstFolder=location.href.split('/')[3];
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #4
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Split the URI string on the solidus character, then ignore the first three parts (the URI scheme 'http:' usually, an empty string '', and the domain name respectively). The first one after that will be the first of those directories, and so on. (You might want to throw away anything that appears after a question mark in the URI as well, if you're using GET requests with query parameters anywhere on the site.)
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #5
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #6
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Quote Originally Posted by Kor View Post
    Except I merged the threads here, so that one is gone.


    Still, garry70: Please don't post in the Post a JavaScript forum unless you have a finished and useful script to share with the world. Please don't post the same question three times, once is enough. And if you notice you're not asking it in the right forum, please ask a moderator for the forum you posted it in to move it.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards


  •  

    Posting Permissions

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