Link to home
Start Free TrialLog in
Avatar of rurth24
rurth24Flag for United States of America

asked on

Get Folder

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
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

You mean something like

if (location.href.indexOf('home')!=1) document.getElementById('homeDiv').className='selected'
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

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

ASKER CERTIFIED SOLUTION
Avatar of ziffgone
ziffgone
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rurth24

ASKER

Thanks Ziff/mplung...

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

Thanks again.