Solved

Get Folder

Posted on 2009-03-31
5
526 Views
Last Modified: 2012-05-06
Hey all, I'm trying check a file path and active a function.

I'm working with a Navigation bar and a Sub-navigation bar. At start the Sub Nav is turned off via css (display=none)

Want I want to do  is turn the subnav on depending on what channel (folder they are currently in).

Anybody have a idea on how I would check file paths and run the logic behind it? Any help would be great.

Thanks
0
Comment
Question by:rurth24
  • 3
5 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 24036637
You mean something like

if (location.href.indexOf('home')!=1) document.getElementById('homeDiv').className='selected'
0
 
LVL 14

Expert Comment

by:ziffgone
ID: 24040556
Umm, try this.

Note: your id for each sub nav will need to be "sub_nav_%FOLDERNAME%", where %FOLDERNAME% is the name of the folder where this sub nav would be visible.


<script type="text/javascript">
function show SubNav(){
    var getFolder=new Array();
    getFolder=unescape(top.location.href).split('/');
    var folder=getFolder[getFolder.length-2];
    document.getElementById('sub_nav_%FOLDERNAME%').style.display='block';
}
window.onload=SubNav();
</script>

Open in new window

0
 
LVL 14

Expert Comment

by:ziffgone
ID: 24040561
Sorry, that code should have been this:


<script type="text/javascript">
function show SubNav(){
    var getFolder=new Array();
    getFolder=unescape(top.location.href).split('/');
    var folder=getFolder[getFolder.length-2];
    document.getElementById('sub_nav_'+folder).style.display='block';
}
window.onload=SubNav();
</script>

Open in new window

0
 
LVL 14

Accepted Solution

by:
ziffgone earned 500 total points
ID: 24040570
Darn, I must be tired. Just came off night shift :(

Disregard the above two examples and go with this:


<script type="text/javascript">
function showSubNav(){
    var getFolder=new Array();
    getFolder=unescape(top.location.href).split('/');
    var folder=getFolder[getFolder.length-2];
    document.getElementById('sub_nav_'+folder).style.display='block';
}
window.onload=showSubNav();
</script>

Open in new window

0
 

Author Comment

by:rurth24
ID: 24040583
Thanks Ziff/mplung...

I'm going to test this out shortly and let you know the outcome...

Thanks again.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Date on a table 16 33
How to get text of href without any ID using Javascript 9 23
Html using "Or" in condition 3 25
Slush on text 2 10
This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question