INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

relative/absolute paths....

relative/absolute paths....

(OP)
Hi (as usual smile ) I'm after a bit of guidance/help please....

I have a local html/javascript based image gallery "website" used to display my digital pictures.

it uses a javascript menu/navigation bar which I have on all pages but with the "site" spread across multiple folder levels I'm having to maintain 3 copies of the js code
which as the site/number of pictures I take grows is becoming a pain...

My site is fairly basic in that its got


website      (Top level html main menu page - js here)
   year1     (gallery index with the js menu here too)
     htmlp1  (thumbnail pages again with the js menu)
     htmlp2
   year2
     htmlp1
     htmlp2
   year3
     htmlp1
     htmlp2
     htmlp3
   ...
   year 17 etc 
     htmlp1
     htmlp2 
   sitefiles
     js
     css
     images

in the js menu I refer to base images, urls etc via href/src tags and currently use relative references 
i.e src='sitefiles/images/image1.jpg' 
however whilst 99% of the code is then identical for the 2nd folder level pages i have to use  
    src='../sitefiles/images/image1.jpg' 
and the lower level thumbnail pages
    src='../../sitefiles/images/image1.jpg'
 

CODE --> javascript

document.write("    <li><a href='2002/00_General/default.htm'>		<img src='sitefiles/webimage/Odd_Small.png'>		<b> 00: General 2002</b> - General Pictures 						<img src='sitefiles/webimage/close.png'></a></li>");
document.write("    <li><a href='2003/00_General/default.htm'>		<img src='sitefiles/webimage/Odd_Small.png'>		<b> 00: General 2003</b> - General Pictures 						<img src='sitefiles/webimage/close.png'></a></li>"); 

I know I can probably use something like src="file://d:/website/sitefiles/images/image1.jpg' but that just seems to cause it to grow in size (3 times per gallery/sub gallery) and
this then becomes equally unmanageable....

So wonder if there's a "better/easier" way of achieving this so I can ultimately use a single piece of js on every page/throughout the site..?

Shout if you need more info and Thanks...

PaulSc

RE: relative/absolute paths....

Could you have a variable pointing to the parent directory

CODE

var sitefiles = "../../sitefiles"
document.write(" .... <img src='" + sitefiles + "webimage/... ") 
Alternatively

CODE

var sitefiles = Server.Mappath("/sitefiles") 

Will runat="server" will work for you. I was thinking along the lines of

CODE

<img runat="server" src="~/sitefiles/...."> 
but I have never tried it in a document.write

RE: relative/absolute paths....

Quote:

but with the "site" spread across multiple folder levels

Just use 'root relative addressing' in that case and specify all paths from the site root.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.

RE: relative/absolute paths....

(OP)
Thanks for the suggestion(s)..I've got it working now...

I ended up using a "plugin" javascript (from http://www.cryer.co.uk/resources/javascript/script...)
and the 1st of xwb's examples to set some vars to pass in...

Chris, your way worked too, but only if site was run as a "web" site (i.e via IIS/localhost)..unfortunately (I should have said) that option isn't available to me at present so I needed it on a pure client based solution..

Thanks for the suggestions which all helped point me to a better way of doing this..

Cheers

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close