MikeCou
Technical User
- Apr 23, 2009
- 10
Can someone please tell me what is wrong in the var part of this code? I'm still trying to come up with a better plan than using absolute paths and this is one option that was suggested to a member of this forum about 3 years ago. I've tried different combinations to no avail.
I am trying to load the subfolder path name(news and show_tell) as a variable and want anything other than that to just follow te path as written. All other html files are in the root folder.
I have no idea what I'm doing. The coding is part of the navigation bar for which is now using absolute paths for everything. I'd like to re-use some of the stuff for other designs if I could and relative paths are much easier to code, not to mention using much less bandwidth.
Here is the code:
************
function LoadNav() {
var path = '';
if (location.href.indexOf('\/show_tell\/') > -1)
{
path = './show_tell';
}
else if (location.href.indexOf('\/news\/') > -1)
{
path = './news';
}
document.write("<div class='navItem2'><a href='./index.html'>Home</a></div>");
document.write("<div class='navItem2'><a href='./meetings.html'>Meetings</a></div>");
document.write( "<ul><li class='folder'>");
document.write( "<div class='navItem2'><div class='expand'><a href='#'>Show 'n Tell</a></div></div>");
document.write( "<ul>");
document.write("<li><a href='' + path + 'show_tell/0209.html'>February 2009</a></li>");
document.write("<li><a href='' + path + 'show_tell/0309.html'>March 2009</a></li>");
document.write("<li><a href='' + path + 'show_tell/0409.html'>April 2009</a></li>");
document.write( "</ul>");
document.write("</li></ul>");
document.write( "<ul><li class='folder'>");
document.write( "<div class='navItem2'><div class='expand'><a href='#'>Newsletters</a></div></div>");
document.write( "<ul>");
document.write("<li><a href='' + path + 'news/march_209_news.html'>March 2009</a></li>");
document.write("<li><a href='' + path + 'news/april_209_news.html'>April 2009</a></li>");
document.write( "</ul>");
document.write("</li></ul>");
document.write("<div class='navItem2'><a href='./Members.html'>Members Directory</a></div>");
document.write("<div class='navItem2'><a href='./events.html'>Special & Upcoming Events</a></div>");
}
**************
Thanks
Mike
I am trying to load the subfolder path name(news and show_tell) as a variable and want anything other than that to just follow te path as written. All other html files are in the root folder.
I have no idea what I'm doing. The coding is part of the navigation bar for which is now using absolute paths for everything. I'd like to re-use some of the stuff for other designs if I could and relative paths are much easier to code, not to mention using much less bandwidth.
Here is the code:
************
function LoadNav() {
var path = '';
if (location.href.indexOf('\/show_tell\/') > -1)
{
path = './show_tell';
}
else if (location.href.indexOf('\/news\/') > -1)
{
path = './news';
}
document.write("<div class='navItem2'><a href='./index.html'>Home</a></div>");
document.write("<div class='navItem2'><a href='./meetings.html'>Meetings</a></div>");
document.write( "<ul><li class='folder'>");
document.write( "<div class='navItem2'><div class='expand'><a href='#'>Show 'n Tell</a></div></div>");
document.write( "<ul>");
document.write("<li><a href='' + path + 'show_tell/0209.html'>February 2009</a></li>");
document.write("<li><a href='' + path + 'show_tell/0309.html'>March 2009</a></li>");
document.write("<li><a href='' + path + 'show_tell/0409.html'>April 2009</a></li>");
document.write( "</ul>");
document.write("</li></ul>");
document.write( "<ul><li class='folder'>");
document.write( "<div class='navItem2'><div class='expand'><a href='#'>Newsletters</a></div></div>");
document.write( "<ul>");
document.write("<li><a href='' + path + 'news/march_209_news.html'>March 2009</a></li>");
document.write("<li><a href='' + path + 'news/april_209_news.html'>April 2009</a></li>");
document.write( "</ul>");
document.write("</li></ul>");
document.write("<div class='navItem2'><a href='./Members.html'>Members Directory</a></div>");
document.write("<div class='navItem2'><a href='./events.html'>Special & Upcoming Events</a></div>");
}
**************
Thanks
Mike